Home > Mobile >  Unable to use .contains() with LINQ to Entities
Unable to use .contains() with LINQ to Entities

Time:06-08

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

CodePudding user response:

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))
  • Related