Mixing LINQ to SQL with properties of objects in a generic list

Posted by BPotocki on Stack Overflow See other posts from Stack Overflow or by BPotocki
Published on 2010-05-18T22:00:53Z Indexed on 2010/05/18 22:10 UTC
Read the original article Hit count: 165

Filed under:
|
|

I am trying to accomplish something like this query:

var query = from a in DatabaseTable
            where listOfObjects.Any(x => x.Id == a.Id)
            select a;

Basically, I want to filter the results where a.Id equals a property of one of the objects in the generic list "listOfObjects". I'm getting the error "Local sequence cannot be used in LINQ to SQL implementation of query operators except the Contains() operator."

Any ideas on how to filter this in an easily readable way using "contains" or another method?

Thanks in advance.

© Stack Overflow or respective owner

Related posts about LINQ

Related posts about c#