We are using EF for our data access and we have a query like this:
Expression<TTable, bool> expression = CreateSomeExpression();
var filter = finalExpression.Compile();
var results = db.t_Table.Where(filter).Select(x=>...);
My question is, will EF construct the correct query given a compiled expression?
As an example, if my table is:
t_Table
( key int,
value_1 varchar(30),
value_2 varchar(30)
)
And the expression to be compiled is
p => p.value_1 = 100
will this translate (in EF) to:
select * from t_Table where value_1 = 100
or will it translate to
select * from t_Table
followed by a linq query on the results?
Is there a way to check what sql query will actually be called on the DB by EF?
Many thanks in advance,
Update
Whilst the accepted answer is 100% correct (and therefore is the accepted answer), the solution to my problem was to simply remove the compilation. Removing that resulted in the correct SQL query with the correct where clause
.