Im not sure wether this is possible or not. I'd like to create an array (or list/dictionary) containing some simple id's and the use the array (or whatever) in a lambda expression.
The example below should return the UserId's 15850 and 15858
DbDataContext db = new DbDataContext();
int[] userIds = {15850, 15858};
var users = db.tblUsers.Where(x => x.UserId.Equals(userIds));
Possible or not?
Thanks
It's possible, and will translate into a SQL WHERE IN (...)
statement, but it is written kind of backwards in linq:
DbDataContext db = new DbDataContext();
int[] userIds = {15850, 15858};
var users = db.tblUsers.Where(x => userIds.Contains(x.UserId));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With