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

Query: compilation error in during tracking for query with GroupBy, orderby, take, skip, distinct and another order by #12641

Closed
maumar opened this issue Jul 12, 2018 · 1 comment

Comments

@maumar
Copy link
Contributor

maumar commented Jul 12, 2018

query:

ctx.Orders
  .GroupBy(o => o.CustomerID)
  .OrderBy(g => g.Key)
  .Take(5)
  .Skip(3)
  .Distinct()
  .OrderBy(e => e.Key)
  .ToList();

exception:

Expression of type 'System.Collections.Generic.List`1[System.Func`2[System.Linq.IGrouping`2[System.String,Microsoft.EntityFrameworkCore.TestModels.Northwind.Order],System.Object]]' cannot be used for parameter of type 'System.Collections.Generic.IList`1[System.Func`2[Microsoft.EntityFrameworkCore.TestModels.Northwind.Order,System.Object]]' of method 'System.Collections.Generic.IEnumerable`1[System.Linq.IGrouping`2[System.String,Microsoft.EntityFrameworkCore.TestModels.Northwind.Order]] _TrackGroupedEntities[String,Order](System.Collections.Generic.IEnumerable`1[System.Linq.IGrouping`2[System.String,Microsoft.EntityFrameworkCore.TestModels.Northwind.Order]], Microsoft.EntityFrameworkCore.Query.QueryContext, System.Collections.Generic.IList`1[Microsoft.EntityFrameworkCore.Query.Internal.EntityTrackingInfo], System.Collections.Generic.IList`1[System.Func`2[Microsoft.EntityFrameworkCore.TestModels.Northwind.Order,System.Object]])'
	at System.Linq.Expressions.Expression.ValidateOneArgument(MethodBase method, ExpressionType nodeKind, Expression arg, ParameterInfo pi)
	at System.Linq.Expressions.Expression.Call(MethodInfo method, Expression arg0, Expression arg1, Expression arg2, Expression arg3)
	at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.TrackEntitiesInResults[TResult](QueryModel queryModel)
	at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateQueryExecutor[TResult](QueryModel queryModel)
	at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](QueryModel queryModel)
	--- End of stack trace from previous location where exception was thrown ---
	at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
	at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](Expression query, IQueryModelGenerator queryModelGenerator, IDatabase database, IDiagnosticsLogger`1 logger, Type contextType)
	at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass13_0`1.<Execute>b__0()
	at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func`1 compiler)
	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 Remotion.Linq.QueryableBase`1.System.Collections.IEnumerable.GetEnumerator()
	at Microsoft.EntityFrameworkCore.TestUtilities.ProcedurallyGeneratedQueryExecutor.Execute[TElement](IQueryable`1 query)
	at Microsoft.EntityFrameworkCore.TestUtilities.QueryAsserter`1.<AssertQuery>d__11`1.MoveNext()
	--- End of stack trace from previous location where exception was thrown ---
	at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
	at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
	at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
	at Microsoft.EntityFrameworkCore.Query.GroupByQuerySqlServerTest.<GroupBy_with_orderby_take_skip_distinct>d__138.MoveNext()
	--- End of stack trace from previous location where exception was thrown ---
	at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
	at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
	--- End of stack trace from previous location where exception was thrown ---
	at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
	at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
	--- End of stack trace from previous location where exception was thrown ---
	at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
	at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
``
@smitpatel
Copy link
Member

Duplicate of #17068

@smitpatel smitpatel marked this as a duplicate of #17068 Sep 10, 2019
@smitpatel smitpatel removed this from the Backlog milestone Sep 10, 2019
@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
Projects
None yet
Development

No branches or pull requests

4 participants