score:1

query.Where(x => x.DomainType == "AT" || x.DomainType == "KS")
     .Where(y => y.DomainType != "AT" || other filter)
     .Where(z => z.DomainType != "KS" || other filter);

score:2

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.


Related Articles