asp.net - C# using Linq in Querable -


i'm bit new linq , hoping me on i'm strugling.

i have 2 list

public iqueryable<trole> roles {       {       var roles = new list<trole>();       roles.add(createidentityrole("chairman", "voorzitter"));       roles.add(createidentityrole("treasurer", "penningmeester"));       roles.add(createidentityrole("ranking responsible", "rankingverantwoordelijke"));                 roles.add(createidentityrole("competition responsible", "competitieverantwoordelijke"));       roles.add(createidentityrole("webmaster", "webbeheerder"));       roles.add(createidentityrole("secretary", "secretaris"));       foreach(trole role in roles)       {          if (!_roles.contains(role))             _roles.add(role);       }        return _roles.asqueryable<trole>();    } }  private trole createidentityrole(string id, string name) {    trole role = (trole)activator.createinstance(typeof(trole));    role.id = id;    role.name = name;    return role; }  public void initializeprivacy(identityuser user) {    var manager = context.getowincontext().getusermanager<applicationusermanager>();    var rolemanager = new rolestore<identityrole>();    var roles = rolemanager.roles;    list<string> userroles = manager.getroles(user.id); } 

right want use linq roles not found in userroles. because roles querable not how achieve such result.

you can use ienumerable interface. if method return querable result work. try this:

ienumerable<string> roles = rolemanager.roles; list<string> userroles = getroles(user.id);  var result = roles.except(userroles); 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -