I am using LINQ Entity framework. I have a SQL table and I want to get all the items in the table that have an ID that exist in a List
Is this possible with LINQ?
Yes, it is possible.
(from item in yourContext.YourTable where yourList.Contains(item.ID) select item).ToList();
You can do this with Contains
its translated into sql IN
:
context.SomeTable.Where(r => someListOfId.Contains(r.ID));
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