Accepted answer

what you have is correct. this will be translated into an in clause in sql with the values supplied in the collection.

on an unrelated note, you should try ordering the query by date descending and use firstordefault(). as it is now, you're going to bring back the entire result set and throw away every row but one.


this will translate into efficient sql, so there's no need to use anything else.


you should be careful with such queries with list.contains() inside of linq query. because for each list element it will create a param in sql statement.

and there's a limited number of params allowed in sql statement, <= 2100. so if your theids will contains more than 2100 elements it will fail.

if you want to use in this way, you should at least check your theids count and if more then 2100 dived it in pieces with less then 2100 elements.

Related Query

More Query from same tag