c# - LINQ Select Based on Another Select -


i find myself stuck on linq in same place. cannot make linq techniques stick in head.

var groupids = context.set<usercontrol>().where(x => x.systemuserid == system.convert.toint32(userid)).select(x => x.systemgroupid); {     var usergroups = context.set<group>().where(g => g.groupid)     {         groups.addrange(usergroups.select(sysgroup => new toolusergroup(sysgroup.groupname, sysgroup.groupid.tostring())));     } } 

i'm trying select list of group objects based on groupid property of list selected in first list of usercontrol ids. cannot figure out syntax.

i'm not sure easier writing sql hand ... linq appear me more complex , abstract writing sql.

i assuming, trying select list based on list of items.

var groupids = context.set<usercontrol>()                   .where(x => x.systemuserid ==system.convert.toint32(userid))                   .select(x => x.systemgroupid);                   .tolist();  var usergroups = context.set<group()                         .where(g=>groupids.contains(g.groupid)).tolist(); 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -