John John - 2 months ago 17
C# Question

using multiple clauses in where

what is the correct way to include multiple wheres in a LINQ call for OR

List<Pos> posList = DbContext.PosList.Where<Pos>(p => p.Pos == "51000785" || p => p.Pos == "123").ToList<Pos>();

Answer Source

The Linq where clause takes one expression and returns one bool value. Yours is taking two expressions each with their own return value. You would need to combine these two into one lambda expression that returns one value rather than the two separate ones in your example.

List<Pos> posList = DbContext.PosList
         .Where<Pos>(p => p.Pos == "51000785" || p.Pos == "123")