Eli
Eli

Reputation: 569

Unable to use .contains() with LINQ to Entities

I am attempting to filter a database column by a list of integers from a separate query in LINQ to entities. My code is below:

 var byProcs = db.ProcedureLabs.Where(x => x.LabID == labID).Select(x=>x.ProcID).ToList();
 var actProcs = db.Procedures.Where(x=>x.id.Contains(byProcs));

I want to take the list of byProcs and filters the actProcs. Both are integers.

When I try using the db.Procedures.Where(x=>x.id.Contains(byProcs)) I get the following error message:

No overload for method 'Contains' takes 0 arguments.

I have looked at many examples of filtering a entry by a list of entries, and contains is always used, what am I missing?

Thank you

Upvotes: 1

Views: 55

Answers (1)

Nigel
Nigel

Reputation: 3311

It's hard to tell what the types of your variables and properties are, but I assume you are trying to do this:

db.Procedures.Where(x=>byProcs.Contains(x.id))

Upvotes: 1

Related Questions