Errors when works with EfCore 3.1
Closed this issue · 2 comments
dingsongjie commented
v0.14.6
When I set PreCompileReadQuery=true
Errors:
System.InvalidOperationException: An exception was thrown while attempting to evaluate the LINQ query parameter expression 'Invoke(value(Orleans.Providers.EntityFramework.Conventions.GrainStorageConvention+<>c__DisplayClass8_5`3[Backet.Api.Infrastructure.BacketDbContext,Backet.Api.Grains.BacketGrain,Backet.Api.Domain.AggregatesModel.BacketAggregate.Backet]).CS$<>8__locals5.options.DbSetAccessor, value(Backet.Api.Infrastructure.BacketDbContext)).SingleOrDefault(value(Orleans.Providers.EntityFramework.Conventions.GrainStorageConvention+<>c__DisplayClass8_5`3[Backet.Api.Infrastructure.BacketDbContext,Backet.Api.Grains.BacketGrain,Backet.Api.Domain.AggregatesModel.BacketAggregate.Backet]).predicate)'.
---> System.Collections.Generic.KeyNotFoundException: The given key '__grainKey' was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Microsoft.EntityFrameworkCore.Query.Internal.ParameterValueBasedSelectExpressionOptimizer.ParameterNullabilityBasedSqlExpressionOptimizingExpressionVisitor.VisitSqlBinaryExpression(SqlBinaryExpression sqlBinaryExpression)
at Microsoft.EntityFrameworkCore.Query.Internal.SqlExpressionOptimizingExpressionVisitor.VisitExtension(Expression extensionExpression)
at Microsoft.EntityFrameworkCore.Query.Internal.ParameterValueBasedSelectExpressionOptimizer.ParameterNullabilityBasedSqlExpressionOptimizingExpressionVisitor.VisitExtension(Expression extensionExpression)
at System.Linq.Expressions.Expression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at Microsoft.EntityFrameworkCore.Query.SqlExpressions.SelectExpression.VisitChildren(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.VisitExtension(Expression node)
at Microsoft.EntityFrameworkCore.Query.Internal.SqlExpressionOptimizingExpressionVisitor.VisitSelectExpression(SelectExpression selectExpression)
at Microsoft.EntityFrameworkCore.Query.Internal.SqlExpressionOptimizingExpressionVisitor.VisitExtension(Expression extensionExpression)
at Microsoft.EntityFrameworkCore.Query.Internal.ParameterValueBasedSelectExpressionOptimizer.ParameterNullabilityBasedSqlExpressionOptimizingExpressionVisitor.VisitExtension(Expression extensionExpression)
at System.Linq.Expressions.Expression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at Microsoft.EntityFrameworkCore.Query.Internal.ParameterValueBasedSelectExpressionOptimizer.Optimize(SelectExpression selectExpression, IReadOnlyDictionary`2 parametersValues)
at Microsoft.EntityFrameworkCore.Query.Internal.RelationalCommandCache.GetRelationalCommand(IReadOnlyDictionary`2 parameters)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.Enumerator.InitializeReader(DbContext _, Boolean result)
at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.Enumerator.MoveNext()
at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression)
at System.Linq.Queryable.SingleOrDefault[TSource](IQueryable`1 source, Expression`1 predicate)
at lambda_method(Closure )
at Microsoft.EntityFrameworkCore.Query.Internal.ParameterExtractingExpressionVisitor.GetValue(Expression expression, String& parameterName)
--- End of inner exception stack trace ---
at Microsoft.EntityFrameworkCore.Query.Internal.ParameterExtractingExpressionVisitor.GetValue(Expression expression, String& parameterName)
at Microsoft.EntityFrameworkCore.Query.Internal.ParameterExtractingExpressionVisitor.Evaluate(Expression expression, Boolean generateParameter)
at Microsoft.EntityFrameworkCore.Query.Internal.ParameterExtractingExpressionVisitor.Visit(Expression expression)
at Microsoft.EntityFrameworkCore.Query.Internal.ParameterExtractingExpressionVisitor.ExtractParameters(Expression expression)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExtractParameters(Expression query, IParameterValues parameterValues, IDiagnosticsLogger`1 logger, Boolean parameterize, Boolean generateContextAccessors)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CreateCompiledAsyncQuery[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledAsyncTaskQuery`2.CreateCompiledQuery(IQueryCompiler queryCompiler, Expression expression)
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryBase`2.<>c__DisplayClass6_0.<EnsureExecutor>b__0(TContext c, LambdaExpression q)
at Microsoft.EntityFrameworkCore.Internal.NonCapturingLazyInitializer.EnsureInitialized[TParam1,TParam2,TValue](TValue& target, TParam1 param1, TParam2 param2, Func`3 valueFactory)
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryBase`2.EnsureExecutor(TContext context)
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryBase`2.ExecuteCore(TContext context, CancellationToken cancellationToken, Object[] parameters)
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryBase`2.ExecuteCore(TContext context, Object[] parameters)
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledAsyncTaskQuery`2.ExecuteAsync[TParam1](TContext context, TParam1 param1)
at Orleans.Providers.EntityFramework.Conventions.GrainStorageConvention.<>c__DisplayClass8_5`3.<CreatePreCompiledDefaultReadStateFunc>b__9(TContext context, IAddressable grainRef) in d:\Source\Repos\Pole\src\Pole.Orleans.Provider.EntityframeworkCore\Conventions\GrainStorageConvention.cs:line 284
When I set PreCompileReadQuery=false
Errors:
The LINQ expression 'DbSet<Backet>
.Where(b => Invoke(__options_KeyExtSelector_0, b[Backet])
== __keyExt_1)' 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 either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync(). See https://go.microsoft.com/fwlink/?linkid=2101038 for more information
dingsongjie commented
alirezajm commented
@dingsongjie Thanks, I'll add some tests for this issue nad release a new version in a few days.