c# - Second Linq filter for multiple conditions -
i have class (simplified) follows:
class appmeta { public int id { get; set; } public string scope { get; set; } public user createdby { get; set; } }
i've created linq statement filters results cross referencing list of integers, , discarding matches:
var hiddenapps = list<int>(); //populate hiddenapps var listitems = list<rawdata>; //populate listitems list<appmeta> apps = appmeta.collection(listitems).where(i => !hiddenapps.contains(i.id)).tolist()
my question is, need further filter list follows,
(where scope == "user" && user.loginname == currentuser.loginname)
can still in 1 linq statement, i.e. can combine line above? what's best way this?
you can specify multiple conditions in where
clause. modify clause as:
.where(i => !hiddenapps.contains(i.id) && i.scope == "user" && i.createdby.loginname == currentuser.loginname )
so query be:
list<appmeta> apps = appmeta.collection(listitems) .where(i => !hiddenapps.contains(i.id) && i.scope == "user" && i.createdby.loginname == currentuser.loginname) .tolist();
Comments
Post a Comment