In some cases, I need to be able to build a query that has a variable set of OR conditions. This is not simple with the default language constructs and extension methods.

It’s simple to dynamically build an expression that includes AND parameters, because that is what the WHERE() extension method does. Not so easy for OR’ing together a bunch of conditions.

Enter LinqKit.

This is a great library. It provides some easy to use (but powerful) extension methods that let you “Or()” some conditions together. A common case is where you get a list of values that you need to add into the condition. You iterate over these and append them to an expression in a foreach() loop. Check out the LinqKit page for some great samples and explanations. I’d share some of my stuff, but their page is already awesome.

Cheers!