You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Processing of the LINQ expression 'GroupByShaperExpression ... by 'RelationalProjectionBindingExpressionVisitor' failed. This may indicate either a bug or a limitation in EF Core
#24695
Closed
larsholm opened this issue
Apr 20, 2021
· 3 comments
Simple join followed by a group by produces the posted exception. The code in repo is heavily reduced from original.
What we have tried: Rewrite to let statement, using Navigation Properties, using latest preview. Unfortunately we cannot ToList or similar, as this later gets paged. ToList in Select does not work either.
TMG2_ALWContextcontext=new TMG2_ALWContext();IQueryable<CountryGroupToEquityFactor>query=fromCountryGroupToEquityFactorrecordin
context.Set<CountryGroupToEquityFactor>()selectrecord;IQueryable<CountryGroupToEquityFactorOutDto>result=fromCountryGroupToEquityFactormodelinquery
join
CountryGroupToEquityFactorView v
in
context.Set<CountryGroupToEquityFactorView>()
on
model.RecordId equals v.RecordId
group v by new{ model.RecordId, v.CountryGroupRatingCurrencyRecordId, v.CountryGroupId, v.CurrencyId, v.RatingSchemeRecordId, v.SchemeName, v.Default }into tempselectnew CountryGroupToEquityFactorOutDto(){CountryGroupId= temp.Key.CountryGroupId,CurrencyId= temp.Key.CurrencyId,RatingSchemeRecordId= temp.Key.RatingSchemeRecordId,RecordId= temp.Key.CountryGroupRatingCurrencyRecordId,SchemeName= temp.Key.SchemeName,DefaultGroup= temp.Key.Default,EquityFactorValues=(fromtintempselectnew EquityFactorValuesOutDto{EquityFactorId= t.EquityFactorId,FromAmountInclusive= t.FromAmountInclusive,RecordId= t.RecordId,Rank= t.Rank,EquityFactorRecordId= t.EquityFactorRecordId})};
Include stack traces
System.InvalidOperationException
HResult=0x80131509
Message=Processing of the LINQ expression 'GroupByShaperExpression:
KeySelector: new {
RecordId = c.RecordId,
CountryGroupRatingCurrencyRecordId = c.CountryGroupRatingCurrencyRecordId,
CountryGroupId = c.CountryGroupId,
CurrencyId = c.CurrencyId,
RatingSchemeRecordId = c.RatingSchemeRecordId,
SchemeName = c.SchemeName,
Default = c.Default
},
ElementSelector:EntityShaperExpression:
EntityType: CountryGroupToEquityFactorView Keyless
ValueBufferExpression:
ProjectionBindingExpression: EmptyProjectionMember
IsNullable: True
' by 'RelationalProjectionBindingExpressionVisitor' failed. This may indicate either a bug or a limitation in Entity Framework. See https://go.microsoft.com/fwlink/?linkid=2101433 for more detailed information.
Source=Microsoft.EntityFrameworkCore.Relational
StackTrace:
at Microsoft.EntityFrameworkCore.Query.Internal.RelationalProjectionBindingExpressionVisitor.VisitExtension(Expression extensionExpression)
at System.Linq.Expressions.Expression.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.VisitMethodCall(MethodCallExpression methodCallExpression)
at System.Linq.Expressions.MethodCallExpression.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.VisitMemberAssignment(MemberAssignment memberAssignment)
at System.Linq.Expressions.ExpressionVisitor.VisitMemberBinding(MemberBinding node)
at Microsoft.EntityFrameworkCore.Query.Internal.RelationalProjectionBindingExpressionVisitor.VisitMemberInit(MemberInitExpression memberInitExpression)
at System.Linq.Expressions.MemberInitExpression.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.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__DisplayClass9_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression)
at System.Linq.Queryable.Count[TSource](IQueryable`1 source)
at ConsoleApp1.Program.Main(String[] args) in C:\Users\dev\Downloads\ConsoleApp1\ConsoleApp1\ConsoleApp1\Program.cs:line 57
EquityFactorValues is term in projection after group by which doesn't apply aggregate. It is limitation of GroupBy currently that you can only select key terms or aggregate operation over grouping in projection after group by.
Simple join followed by a group by produces the posted exception. The code in repo is heavily reduced from original.
What we have tried: Rewrite to let statement, using Navigation Properties, using latest preview. Unfortunately we cannot ToList or similar, as this later gets paged. ToList in Select does not work either.
Repo: https://github.com/larsholm/EFrepo
Run CreateSQLObjects.sql before building and running project. Change conn string in TMG2_ALWContext.cs:36
Include stack traces
Include provider and version information
EF Core version: 5.0.5
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 5.0
Operating system: Win 10
IDE: Visual Studio 2019 16.10.0 Preview 2.0
The text was updated successfully, but these errors were encountered: