query.Where(x => x.DomainType == "AT" || x.DomainType == "KS") .Where(y => y.DomainType != "AT" || other filter) .Where(z => z.DomainType != "KS" || other filter);
It's really not all that different than what you might write in SQL. In fact, if you would try the query expression syntax approach, you might find that particular connection easier to make.
var query = from domain in db.DomainSequences where (domain.DomainType == "AT" && domain.Foo == 42 && ...) || (domain.DomainType == "KS" && domain.Foo = 117 && ...) select domain;
That maps nicely to the SQL you might expect to write
SELECT * FROM DomainSequences WHERE (DomainType = 'AT' AND Foo = 42 AND ...) OR (DomainType = 'KS' AND Foo = 117 AND ...)
You could, of course, keep it in the fluent extension method syntax using lambdas, of course, it's just a single
.Where(...) invocation, after all.
- LINQ to SQL: subfilter in where conditions
- How can I make this LINQ to SQL where clause with conditions faster?
- LINQ to SQL - Left Outer Join with multiple join conditions
- LINQ to SQL Where Clause Optional Criteria
- How are people unit testing code that uses Linq to SQL
- LINQ query to perform a projection, skipping or wrapping exceptions where source throws on IEnumerable.GetNext()
- using Linq with multiple where conditions
- two conditions checking in where clause using linq 2 entites
- linq to sql query with multiple where parameters
- Linq to SQL multiple conditional where clauses
- LINQ to SQL - Why can't you use a WHERE after an ORDER BY?
- LINQ WHERE method alters source collection
- Where to find translated Linq to Entity query to Sql
- LINQ query with a WHERE clause with multiple conditions
- Where can I view LINQ source code?
- LINQ to SQL - select where text like string array
- LINQ WHERE statement/ignore conditions
- Linq where clause with multiple conditions and null check
- Linq to entities - SQL Query - Where list contains object with 2 properties (or more)
- Dynamic Where Clause over relational tables with LINQ to SQL
- Expression to get LINQ with Contains to EF for SQL IN() where on entities child's property equals value
- Linq to SQL: Where clause comparing a Nullable<DateTime> with a SQL datetime null column
- Does order of conditions under where clause in a LINQ query matter
- Linq where clause with multiple conditions
- Linq to Sql with lambda sum as a where condition
- LINQ Source Code Available
- LINQ to SQL MAX in WHERE clause
- LINQ to SQL where in (lambda syntax)
- Linq with optional Where clauses and Sql Server CE
- How to perform 'OR' operation between several where conditions in LINQ
More Query from same tag
- How do I get the closest DateTime from a List<DateTime>
- .NET LINQ IQueryable: what is `Expression` for?
- LinqtoSQL filter and order by syntax
- How to search multiple folders for Files with a certain substring in Filename using c#?
- Most recent records with 2 tables and take / skip
- Linq where clause "if item is not null, evaluate, otherwise, get all data"
- how to get DataGridViewColumns out of IOrderedEnumerable with DataGridviewCell's?
- Alternative to using a ternary operator in Lambda
- How better combine generic lists of different types inherited from one interfase?
- LINQ Custom Sort
- Outer Join tables without foreign key using linq on NHibernate
- Parameter of OfType<????> when used in a method with C#
- LINQ to Entity Select Query Error
- Select -> Refer to itself (currently created list)
- foreach iteration after Select
- linq latests elements that match a criteria
- Nhibernate generating OUTER JOIN for a fetch
- EF LINQ many to one filter/where
- LINQ using Join on a long and long typed properties (one to many variation)
- Convert double for-loop into a linq query
- How do I convert from entity/property names (conceptual) to table/column names (store)? (Trial code [in VB 2010 and EF 4] uses reflection.)
- Changes to an IEnumerable are not being kept between queries
- Filtering data by LINQ to SQL
- LINQ generating wrong SQL for empty string
- How do I do this with LINQ?
- How to get a single object by LINQ? ERROR: The result of a query cannot be enumerated more than once
- Transaction and TransactionScope isolation
- C# iteration and interpolation syntax
- C# Linq Find all indexes of item in List<int> within another List<int>
- How to get the index from 2 different lists which matches values from 3rd list