Closed warappa closed 3 years ago
Thanks for the issue - hoped for no breaking change, but here it is. 🙃
I've planned at least a working build for .NET 6.0 RC1, but didn't find the time yet. You can expect something within the next few days / next week.
Stay tuned. 😎
Wow, you're kidding me 😯
That's a fast fix! Can't wait for the released package! Awesome, thank you! 👍
PS: I manually used InjectableQueryRewriter
for now and after some little knowledge-gathering (re-reading the README - but slower and more precisely) it worked as advertised!
Great project!
You can use the prerelease package as well. 🤞
Thank you! This new package now works with EF Core 6! 🎉
Unfortunately, the global DbContext registration (WithLambdaInjection()
) does not kick in. But I can work around that by using ToInjectable()
or ToEntityInjectable
on the IQueryable<T>
.
Exception without ToInjectable()
but with WithLambdaInjection()
:
Unhandled exception. System.InvalidOperationException: The LINQ expression 'ShapedQueryExpression:
QueryExpression:
Projection Mapping:
EmptyProjectionMember -> EntityProjectionExpression: LocalizedStringValue
SELECT 1
FROM LocalizedStringValues AS l
WHERE l.Id == l.LocalizedStringId
ShaperExpression: EntityShaperExpression:
LocalizedStringPlayground.LocalizedStringValue
ValueBufferExpression:
ProjectionBindingExpression: EmptyProjectionMember
IsNullable: False
.Where(namelessParameter{0} => object.Equals(
objA: (object)EF.Property<Guid>(EntityShaperExpression:
LocalizedStringPlayground.LocalizedString
ValueBufferExpression:
ProjectionBindingExpression: Outer.Outer.Outer.Outer.Inner
IsNullable: True
, "Id"),
objB: (object)EF.Property<Guid>(namelessParameter{0}, "LocalizedStringId")))
.AsQueryable()
.Where(o => o.Culture == CultureInfo.CurrentCulture.Name)' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.<VisitMethodCall>g__CheckTranslated|15_0(ShapedQueryExpression translated, <>c__DisplayClass15_0& )
at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.TranslateSubquery(Expression expression)
at Microsoft.EntityFrameworkCore.Query.RelationalSqlTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at Microsoft.EntityFrameworkCore.Query.RelationalSqlTranslatingExpressionVisitor.TranslateInternal(Expression expression)
at Microsoft.EntityFrameworkCore.Query.RelationalSqlTranslatingExpressionVisitor.Translate(Expression expression)
at Microsoft.EntityFrameworkCore.Query.Internal.RelationalProjectionBindingExpressionVisitor.Visit(Expression expression)
at Microsoft.EntityFrameworkCore.Query.Internal.RelationalProjectionBindingExpressionVisitor.VisitNew(NewExpression newExpression)
at System.Linq.Expressions.NewExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at Microsoft.EntityFrameworkCore.Query.Internal.RelationalProjectionBindingExpressionVisitor.Visit(Expression expression)
at Microsoft.EntityFrameworkCore.Query.Internal.RelationalProjectionBindingExpressionVisitor.Translate(SelectExpression selectExpression, Expression expression)
at Microsoft.EntityFrameworkCore.Query.RelationalQueryableMethodTranslatingExpressionVisitor.TranslateSelect(ShapedQueryExpression source, LambdaExpression selector)
at Microsoft.EntityFrameworkCore.Query.QueryableMethodTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at Microsoft.EntityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutor[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](Expression query, Boolean async)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass12_0`1.<ExecuteAsync>b__0()
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteAsync[TResult](Expression query, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.ExecuteAsync[TResult](Expression expression, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1.GetAsyncEnumerator(CancellationToken cancellationToken)
at System.Runtime.CompilerServices.ConfiguredCancelableAsyncEnumerable`1.GetAsyncEnumerator()
at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
at LocalizedStringPlayground.Program.Main() in some-path\LocalizedStringPlayground\Program.cs:line 119
at LocalizedStringPlayground.Program.<Main>()
I've some basic integration tests for WithLambdaInjection
, where it does kick in (see EntityFrameworkCoreExtensionTest
). Thus, we have to dig deeper a little bit. Do you have a repro for this exception for me?
I will try to provide a repo later today!
Here is a gist that shows the issue: https://gist.github.com/warappa/7b36297f604b4e5774db2e79cf5d0296
I just tested it and I can confirm it's fixed! Thank you for your work! 👍
I am still having trouble with this - .WithLambdaInjection()
does not seem to work, individual .ToEntityInjectable()
calls are still required. I'm running .NET 6.0.3
Can you provide a repro?
I've found the problem.
I wanted to call .WithLambdaInjection()
in the OnConfiguring()
override in my DbContext
.
It seems that the call to .WithLambdaInjection()
must come after the call to UseSqlServer()
.
Maybe worth a mention in the docs (assuming this isn't something that could be fixed)?
Interesting. I'll look into that. Thanks for the research!
I just added one more test Query_WithLambdaInjectionUsingOverride_ResolvesLambdaInjection
. This seems to work... (?)
Actually, I'm doing the same within one of my projects:
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder.WithLambdaInjection();
Maybe there's something else?
Quick thoughts off the top of my head:
services.AddDbContext<TestWithOverrideContext>(options...)
- does the eventual call to options.UseSqlite()
happen before or after the call to .WithLambdaInjection()
in the override?UseSqlServer()
..UseSqlite()
comes first. Thus, the order doesn't change at all (I'll add one more test, which changes the order explicitly...)Yeah, .WithLambdaInjection().UseSqlite()
breaks it
Okay, within the next versionRewriteDbContextOptionsExtension
will throw an error here - thx!
Nice one 👍
Issue
I installed
NeinLinq.EntityFramework.Core
5.1.0
to anet6.0
project usingMicrosoft.EntityFrameworkCore
6.0.0-rc.1.21452.10
. As the major versions differs I was already prepared it might not work - and so it was.An exception was thrown, obviously due to added members in EF Core 6:
Question
Can you say if and when EF Core 6 will be supported?
Environment
.NET: .NET 6 RC1 Project: net6.0 EF Core: Microsoft.EntityFrameworkCore 6.0.0-rc.1.21452.10