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
Post a Comment