Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
i just want to get Communities count as well as if its community delete flag its true then count will be minus. i had wrote below code, its return all count. any suggestion fot that -

Code -

Mapper.CreateMap()
.ForMember(e => e.CommunityCount, ex => ex.MapFrom(s => s.Communities.Count))
.ForSourceMember(e => e.Builder, ex => ex.Ignore());

class file - Brand data model class file have -
public virtual ICollection Communities { get; set; },

in between Community class file have -
"public bool Deleted { get; set; }"

thanks.

What I have tried:

i tried but not getting correct solution
Posted
Updated 12-Sep-18 23:40pm

1 solution

This should work for you

.ForMember(e => e.CommunityCount, ex => ex.MapFrom(s => s.Communities.Where(x=> x.Deleted == false).Count))
 
Share this answer
 
Comments
RajendraKhandekar5525 22-Feb-19 7:00am    
ya...its working ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900