Ehsan Akbar Ehsan Akbar - 3 months ago 9
C# Question

Where condition can be a list in EF?

I have this :

private List<int> linesId = new List<int>();
_materialRepository.ViewLineMaterialStatus()
.Where(i => i.LineId == linesId)
.Tolist();


Can I assign a list in the
where
clause ?

Answer

You can't assign it - but you should be able to query it like this:

private List<int> linesId = new List<int>();
_materialRepository.ViewLineMaterialStatus()
                   .Where(i => linesId.Contains(i.LineId))
                   .Tolist();