Let\'s say we need to apply several conditions to select from a table called \"Things\" (unknown count and nature)
if conditions are known, we can write
For OR
, you have two choices:
Union
/Concat
Expression
in codeThe second is closer to the .Where(x => {a} || {b})
.
If you are using LINQ-to-SQL, you can use Expression.Invoke
to combine multiple separate lambda expressions (see this answer) - however, this isn't supported in Entity Framework. In EF, you have to build the entire expression as a single block, using Expression.OrElse
; for example here or here.