scottksmith95 / LINQKit

LINQKit is a free set of extensions for LINQ to SQL and Entity Framework power users.
MIT License
1.62k stars 162 forks source link

QueryOptimizer with EFCore? #172

Open AudriusButkevicius opened 2 years ago

AudriusButkevicius commented 2 years ago

Not sure whether this should work or not, but I'm struggling to use the query optimizer with EFCore.

Seems that a simple query such as the following one fails:

_context.Items.Include(o => o.Parts).AsExpandable(ExpressionOptimizer.visit).Take(10);

Returns an error:

System.Exception: encountered unknown LINQ expression: Extension [Microsoft.EntityFrameworkCore.Query.QueryRootExpression]

Is this expected?

inf9144 commented 1 year ago

same problem here :-(

https://github.com/Thorium/Linq.Expression.Optimizer/issues/14

Thorium commented 1 year ago

There is a fix now released, hopefully that helps.

StefH commented 1 year ago

@Thorium Should also this project be fixed?

Thorium commented 1 year ago

I thin LinqKit already "handles" the Extension case (or rather, ignores Extensions) and the problem was only with the Linq.Expression.Optimizer.

I don't know why EF Core suddenly needs extensions to ExpressionTrees. So I don't know if the ignoring is the correct design, but definitely it sounds a bit suspicious that we have the LINQ "language" (which was made mathematically properly originally) and then we have some extensions, probably for injecting something impure.

StefH commented 1 year ago

I also don't know why.

I noticed that this new version works nicely with my efcore 6/7 example in this project: https://github.com/StefH/QueryInterceptor.Core