c# - LINQ with List<object> -


i trying fetch few rows db.

with code, 1 specific row.

int mid =1; classa obja = obj1.exp.values.firstordefault(i => i.id == mid); classb objb = obj1.pol.values.firstordefault(i => i.gid == obja.mgid); 

but, want have list of rows, remove firstordefault list. how can ?

list<classa> l_obja = obj1.exp.values.where(i => i.id == mid).tolist(); list<classb> l_objb = obj1.pol.values.where(i=> l_obja.contains(i.mgid)); // rows l_obja.mgid = i.mgid 

i tried this, not work can please me this.

you want use any since l_obja not list of ids.

list<classa> l_obja = obj1.exp.values.where(i => i.id == mid).tolist(); list<classb> l_objb = obj1.pol.values.where(i => l_obja.any(a => a.mgid == i.gid)); 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -