Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration EF6 to EF Core -> Client-Eval of Top-level projection LINQ #27846

Closed
ankitmatrix08 opened this issue Apr 20, 2022 · 1 comment
Closed
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported

Comments

@ankitmatrix08
Copy link

Ref: dotnet/ef6#1963 (comment)
Per our discussion on the above link, @smitpatel mentions that "Given that EF6 also didn't allow client eval other than top level projection and EF Core follows same principle, there is not much gap in terms of client evaluation."

But the sample mentioned here works only in EF Core world and throws exception in EF6.

Exception:
LINQ to Entities does not recognize the method 'System.String StandardizeUrl(System.String)' method, and this method cannot be translated into a store expression.

Stack Trace:

at System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.MethodCallTranslator.DefaultTranslator.Translate(ExpressionConverter parent, MethodCallExpression call) at System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.MethodCallTranslator.TypedTranslate(ExpressionConverter parent, MethodCallExpression linq) at System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TypedTranslator1.Translate(ExpressionConverter parent, Expression linq) at System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq) at System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.NewTranslator.TypedTranslate(ExpressionConverter parent, NewExpression linq) at System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TypedTranslator1.Translate(ExpressionConverter parent, Expression linq) at System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq) at System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateLambda(LambdaExpression lambda, DbExpression input) at System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateLambda(LambdaExpression lambda, DbExpression input, DbExpressionBinding& binding) at System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.MethodCallTranslator.OneLambdaTranslator.Translate(ExpressionConverter parent, MethodCallExpression call, DbExpression& source, DbExpressionBinding& sourceBinding, DbExpression& lambda) at System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.MethodCallTranslator.SelectTranslator.Translate(ExpressionConverter parent, MethodCallExpression call) at System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.MethodCallTranslator.SequenceMethodTranslator.Translate(ExpressionConverter parent, MethodCallExpression call, SequenceMethod sequenceMethod) at System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.MethodCallTranslator.TypedTranslate(ExpressionConverter parent, MethodCallExpression linq) at System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TypedTranslator1.Translate(ExpressionConverter parent, Expression linq) at System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq) at System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.Convert() at System.Data.Entity.Core.Objects.ELinq.ELinqQueryState.GetExecutionPlan(Nullable1 forMergeOption) at System.Data.Entity.Core.Objects.ObjectQuery1.<>c__DisplayClass41_0.b__1() at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess) at System.Data.Entity.Core.Objects.ObjectQuery1.<>c__DisplayClass41_0.b__0() at System.Data.Entity.Infrastructure.DbExecutionStrategy.Execute[TResult](Func1 operation) at Lw.Sys.Repository.CustomDbExecutionStrategy.System.Data.Entity.Infrastructure.IDbExecutionStrategy.Execute[TResult](Func1 operation) in D:\Workspace\LW5\Framework4.0\Dev\Lw.System\Repository\CustomDbExecutionStrategy.cs:line 68 at System.Data.Entity.Core.Objects.ObjectQuery1.GetResults(Nullable1 forMergeOption) at System.Data.Entity.Core.Objects.ObjectQuery1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__31_0() at System.Data.Entity.Internal.LazyEnumerator1.MoveNext() at System.Collections.Generic.List1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at Lw.Sys.Test.SelectorTest.RunAllSelectors() in D:\Workspace\LW5\Framework4.0\Dev\Lw.System.Test\SelectorTests.cs:line 44

Requirement: We are looking for some concrete differentiators (in LINQ) via which we can analyze the code (EF6) during compile time itself and can flag them that they won't work in EF Core world.

@ajcvickers @ErikEJ Need your attention here, thanks!

@smitpatel
Copy link
Contributor

smitpatel commented Apr 22, 2022

I have responded in detail in the linked ef6 issue in the first post.

EF Core follows same principal of allowing client eval in top level projection. This means that we may fetch additional data for columns from the server which helps us in creating final object in results. We don't ever fetch additional rows from server which won't be returned in the result. So above query working in EF Core, we don't plan to change it.

For customers who don't want any kind of client evaluation, we have #24509 which basically disables client eval in top-level projection too. It doesn't make it same as how EF6 worked as EF6 still allowed client eval in top level projection (and has no such hook to change it). That issue is not solution to this question but if you want to go that route for whatever reason, carefully evaluate the consequences.

Apart from #24509 there is nothing actionable on this issue. Closing.

@smitpatel smitpatel added closed-no-further-action The issue is closed and no further action is planned. and removed customer-reported labels Apr 22, 2022
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported
Projects
None yet
Development

No branches or pull requests

3 participants