c# - How to select all objects that have a property value in list of values? -


i have table named items. items have property named "locationid" given list of location ids, how select items?

list example

list<long> locationids = new list<long> { 1, 2, 3 }; 

essentially query below, multiple locations @ once:

var sleecteditems= db.items.select(i => i.locationid == 2); 

you need use where contains:

var selecteditems = db.items.where(x => locationids.contains(x.locationid)); 

Comments