Consider the following Person
entity:
public class Person
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
Using the following Expression
(constructed using PredicateBuilder
) as the criteria:
var byName = PredicateBuilder.True<Person>().And(x => x.FirstName == "Chaim");
When invoked using the following syntax, the generated SQL is fine (includes the WHERE
statement):
ctx.Set<Person>().AsExpandable().Where(x => byName.Invoke(x));
However, when invoked using this slightly different syntax, no SQL WHERE
is involved and the filtering is being done by Enumerable.Where
instead:
ctx.Set<Person>().AsExpandable().Where(byName.Invoke);
Any thoughts?