c# - How to filter elements by a List item in linq? -



c# - How to filter elements by a List item in linq? -

i have user belongs community specific role, classes of user, community, communityrole , communityroletype described bellow:

public class user{ public int userid { get; set;} public list<communityrole> communityroles { get; set; } } public class community{ public int communityid { get; set;} public string name { get; set; } } public enum communityroletype{ type1, type2 } public class communityrole { public community community { get; set; } public communityroletype roletype {get; set; } }

how get, list of users, subset of users belong specific community , assigned specific role??

edit:

var userstype1 = users.where(usr => usr.communityroles.any(role => role.roletype == communityroletype.type1 && role.community.communityid == communityid)).tolist();

c# linq entity-framework-6

Comments

Popular posts from this blog

c - Compilation of a code: unkown type name string -

java - Bypassing "final local variable defined in an enclosing type" -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -