{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/issues/10045","repository_url":"https://api.github.com/repos/aspnet/EntityFrameworkCore","labels_url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/issues/10045/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/issues/10045/comments","events_url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/issues/10045/events","html_url":"https://github.com/aspnet/EntityFrameworkCore/issues/10045","id":264676724,"number":10045,"title":"System.ArgumentOutOfRangeException after upgrade to EF Core 2.0","user":{"login":"joshmouch","id":3098820,"avatar_url":"https://avatars0.githubusercontent.com/u/3098820?v=4","gravatar_id":"","url":"https://api.github.com/users/joshmouch","html_url":"https://github.com/joshmouch","followers_url":"https://api.github.com/users/joshmouch/followers","following_url":"https://api.github.com/users/joshmouch/following{/other_user}","gists_url":"https://api.github.com/users/joshmouch/gists{/gist_id}","starred_url":"https://api.github.com/users/joshmouch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshmouch/subscriptions","organizations_url":"https://api.github.com/users/joshmouch/orgs","repos_url":"https://api.github.com/users/joshmouch/repos","events_url":"https://api.github.com/users/joshmouch/events{/privacy}","received_events_url":"https://api.github.com/users/joshmouch/received_events","type":"User","site_admin":false},"labels":[{"id":333904587,"url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/labels/type-investigation","name":"type-investigation","color":"0052cc","default":false}],"state":"open","locked":false,"assignee":{"login":"smitpatel","id":1528107,"avatar_url":"https://avatars0.githubusercontent.com/u/1528107?v=4","gravatar_id":"","url":"https://api.github.com/users/smitpatel","html_url":"https://github.com/smitpatel","followers_url":"https://api.github.com/users/smitpatel/followers","following_url":"https://api.github.com/users/smitpatel/following{/other_user}","gists_url":"https://api.github.com/users/smitpatel/gists{/gist_id}","starred_url":"https://api.github.com/users/smitpatel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smitpatel/subscriptions","organizations_url":"https://api.github.com/users/smitpatel/orgs","repos_url":"https://api.github.com/users/smitpatel/repos","events_url":"https://api.github.com/users/smitpatel/events{/privacy}","received_events_url":"https://api.github.com/users/smitpatel/received_events","type":"User","site_admin":false},"assignees":[{"login":"smitpatel","id":1528107,"avatar_url":"https://avatars0.githubusercontent.com/u/1528107?v=4","gravatar_id":"","url":"https://api.github.com/users/smitpatel","html_url":"https://github.com/smitpatel","followers_url":"https://api.github.com/users/smitpatel/followers","following_url":"https://api.github.com/users/smitpatel/following{/other_user}","gists_url":"https://api.github.com/users/smitpatel/gists{/gist_id}","starred_url":"https://api.github.com/users/smitpatel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smitpatel/subscriptions","organizations_url":"https://api.github.com/users/smitpatel/orgs","repos_url":"https://api.github.com/users/smitpatel/repos","events_url":"https://api.github.com/users/smitpatel/events{/privacy}","received_events_url":"https://api.github.com/users/smitpatel/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/milestones/33","html_url":"https://github.com/aspnet/EntityFrameworkCore/milestone/33","labels_url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/milestones/33/labels","id":2628183,"number":33,"title":"2.1.0","description":null,"creator":{"login":"ajcvickers","id":1430078,"avatar_url":"https://avatars1.githubusercontent.com/u/1430078?v=4","gravatar_id":"","url":"https://api.github.com/users/ajcvickers","html_url":"https://github.com/ajcvickers","followers_url":"https://api.github.com/users/ajcvickers/followers","following_url":"https://api.github.com/users/ajcvickers/following{/other_user}","gists_url":"https://api.github.com/users/ajcvickers/gists{/gist_id}","starred_url":"https://api.github.com/users/ajcvickers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajcvickers/subscriptions","organizations_url":"https://api.github.com/users/ajcvickers/orgs","repos_url":"https://api.github.com/users/ajcvickers/repos","events_url":"https://api.github.com/users/ajcvickers/events{/privacy}","received_events_url":"https://api.github.com/users/ajcvickers/received_events","type":"User","site_admin":false},"open_issues":190,"closed_issues":94,"state":"open","created_at":"2017-07-07T18:34:47Z","updated_at":"2017-10-11T19:25:34Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2017-10-11T17:47:30Z","updated_at":"2017-10-11T21:21:01Z","closed_at":null,"author_association":"NONE","body":"After upgrading from EF Core 1.1 to 2.0, I started getting an exception when a certain query executes.\r\n\r\nThe code is along the lines of:\r\n```\r\nvar recordsQuery = dataContext.Entities\r\n\t\t\t\t.Include(ar => ar.A)\r\n\t\t\t\t.Include(ar => ar.B)\r\n\t\t\t\t.Include(ar => ar.C.D)   <---- COMMENTING OUT MAKES EXCEPTION GO AWAY\r\n.Where(ar => ... simple filter ...);\r\n\r\nrecordsQuery  = recordsQuery .Where(ar => ... simple filter ...);\r\n\r\nrecordsQuery = recordsQuery.OrderBy(ar => ar.A); // <---- COMMENTING OUT THIS LINE MAKES EXCEPTION GO AWAY\r\n\r\nvar hasAny = recordsQuery.Any(); // <-- THIS LINE *DOES NOT* THROW EXCEPTION\r\nvar records = await recordsQuery.ToListAsync();  // <--- THIS LINE THROWS EXCEPTION\r\n\r\n```\r\n\r\nIf I comment out the line that adds an OrderBy and a ThenBy to the query, the exception goes away.\r\nAlso, if I comment out the Include calls, the exception goes away.\r\n\r\nThe exception is:\r\n\r\n```\r\nSystem.ArgumentOutOfRangeException occurred\r\n  HResult=0x80131502\r\n  Message=Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index\r\n  Source=<Cannot evaluate the exception source>\r\n  StackTrace:\r\n   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)\r\n   at System.Collections.Generic.List`1.get_Item(Int32 index)\r\n   at Microsoft.EntityFrameworkCore.Query.Expressions.SelectExpression.BindSubqueryProjectionIndex(Int32 projectionIndex, IQuerySource querySource)\r\n   at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.SqlTranslatingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)\r\n   at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)\r\n   at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)\r\n   at Remotion.Linq.Parsing.ThrowingExpressionVisitor.Visit(Expression expression)\r\n   at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.SqlTranslatingExpressionVisitor.Visit(Expression expression)\r\n   at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.VisitOrderByClause(OrderByClause orderByClause, QueryModel queryModel, Int32 index)\r\n   at Remotion.Linq.Clauses.OrderByClause.Accept(IQueryModelVisitor visitor, QueryModel queryModel, Int32 index)\r\n   at Remotion.Linq.QueryModelVisitorBase.VisitBodyClauses(ObservableCollection`1 bodyClauses, QueryModel queryModel)\r\n   at Remotion.Linq.QueryModelVisitorBase.VisitQueryModel(QueryModel queryModel)\r\n   at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.VisitQueryModel(QueryModel queryModel)\r\n   at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.VisitQueryModel(QueryModel queryModel)\r\n   at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.RelationalEntityQueryableExpressionVisitor.VisitSubQuery(SubQueryExpression expression)\r\n   at Remotion.Linq.Clauses.Expressions.SubQueryExpression.Accept(ExpressionVisitor visitor)\r\n   at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)\r\n   at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.ExpressionVisitorBase.VisitLambda[T](Expression`1 node)\r\n   at System.Linq.Expressions.Expression`1.Accept(ExpressionVisitor visitor)\r\n   at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)\r\n   at System.Linq.Expressions.ExpressionVisitor.VisitUnary(UnaryExpression node)\r\n   at System.Linq.Expressions.UnaryExpression.Accept(ExpressionVisitor visitor)\r\n   at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)\r\n   at System.Linq.Expressions.ExpressionVisitor.VisitArguments(IArgumentProvider nodes)\r\n   at System.Linq.Expressions.ExpressionVisitor.VisitMethodCall(MethodCallExpression node)\r\n   at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.RelationalEntityQueryableExpressionVisitor.VisitMethodCall(MethodCallExpression node)\r\n   at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)\r\n   at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)\r\n   at System.Linq.Expressions.ExpressionVisitor.VisitBlock(BlockExpression node)\r\n   at System.Linq.Expressions.BlockExpression.Accept(ExpressionVisitor visitor)\r\n   at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)\r\n   at System.Linq.Expressions.ExpressionVisitor.VisitConditional(ConditionalExpression node)\r\n   at System.Linq.Expressions.ConditionalExpression.Accept(ExpressionVisitor visitor)\r\n   at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)\r\n   at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.ExpressionVisitorBase.VisitLambda[T](Expression`1 node)\r\n   at System.Linq.Expressions.Expression`1.Accept(ExpressionVisitor visitor)\r\n   at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)\r\n   at System.Linq.Expressions.ExpressionVisitor.Visit(ReadOnlyCollection`1 nodes)\r\n   at System.Linq.Expressions.ExpressionVisitor.VisitNewArray(NewArrayExpression node)\r\n   at System.Linq.Expressions.NewArrayExpression.Accept(ExpressionVisitor visitor)\r\n   at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)\r\n   at System.Linq.Expressions.ExpressionVisitor.VisitArguments(IArgumentProvider nodes)\r\n   at System.Linq.Expressions.ExpressionVisitor.VisitMethodCall(MethodCallExpression node)\r\n   at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.RelationalEntityQueryableExpressionVisitor.VisitMethodCall(MethodCallExpression node)\r\n   at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)\r\n   at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)\r\n   at System.Linq.Expressions.ExpressionVisitor.VisitBlock(BlockExpression node)\r\n   at System.Linq.Expressions.BlockExpression.Accept(ExpressionVisitor visitor)\r\n   at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)\r\n   at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.ExpressionVisitorBase.VisitLambda[T](Expression`1 node)\r\n   at System.Linq.Expressions.Expression`1.Accept(ExpressionVisitor visitor)\r\n   at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)\r\n   at System.Linq.Expressions.ExpressionVisitor.VisitArguments(IArgumentProvider nodes)\r\n   at System.Linq.Expressions.ExpressionVisitor.VisitMethodCall(MethodCallExpression node)\r\n   at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.RelationalEntityQueryableExpressionVisitor.VisitMethodCall(MethodCallExpression node)\r\n   at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)\r\n   at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)\r\n   at System.Linq.Expressions.ExpressionVisitor.VisitMember(MemberExpression node)\r\n   at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.RelationalEntityQueryableExpressionVisitor.VisitMember(MemberExpression node)\r\n   at System.Linq.Expressions.MemberExpression.Accept(ExpressionVisitor visitor)\r\n   at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)\r\n   at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.ReplaceClauseReferences(Expression expression, IQuerySource querySource, Boolean inProjection)\r\n   at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.VisitSelectClause(SelectClause selectClause, QueryModel queryModel)\r\n   at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.VisitSelectClause(SelectClause selectClause, QueryModel queryModel)\r\n   at Remotion.Linq.Clauses.SelectClause.Accept(IQueryModelVisitor visitor, QueryModel queryModel)\r\n   at Remotion.Linq.QueryModelVisitorBase.VisitQueryModel(QueryModel queryModel)\r\n   at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.VisitQueryModel(QueryModel queryModel)\r\n   at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.VisitQueryModel(QueryModel queryModel)\r\n   at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateAsyncQueryExecutor[TResult](QueryModel queryModel)\r\n   at Microsoft.EntityFrameworkCore.Storage.Database.CompileAsyncQuery[TResult](QueryModel queryModel)\r\n   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileAsyncQueryCore[TResult](Expression query, INodeTypeProvider nodeTypeProvider, IDatabase database)\r\n   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass24_0`1.<CompileAsyncQuery>b__0()\r\n   at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func`1 compiler)\r\n   at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddAsyncQuery[TResult](Object cacheKey, Func`1 compiler)\r\n   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileAsyncQuery[TResult](Expression query)\r\n   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteAsync[TResult](Expression query)\r\n   at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.ExecuteAsync[TResult](Expression expression)\r\n   at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1.System.Collections.Generic.IAsyncEnumerable<TResult>.GetEnumerator()\r\n   at System.Linq.AsyncEnumerable.<Aggregate_>d__6`3.MoveNext()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/issues/comments/335952195","html_url":"https://github.com/aspnet/EntityFrameworkCore/issues/10045#issuecomment-335952195","issue_url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/issues/10045","id":335952195,"user":{"login":"joshmouch","id":3098820,"avatar_url":"https://avatars0.githubusercontent.com/u/3098820?v=4","gravatar_id":"","url":"https://api.github.com/users/joshmouch","html_url":"https://github.com/joshmouch","followers_url":"https://api.github.com/users/joshmouch/followers","following_url":"https://api.github.com/users/joshmouch/following{/other_user}","gists_url":"https://api.github.com/users/joshmouch/gists{/gist_id}","starred_url":"https://api.github.com/users/joshmouch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshmouch/subscriptions","organizations_url":"https://api.github.com/users/joshmouch/orgs","repos_url":"https://api.github.com/users/joshmouch/repos","events_url":"https://api.github.com/users/joshmouch/events{/privacy}","received_events_url":"https://api.github.com/users/joshmouch/received_events","type":"User","site_admin":false},"created_at":"2017-10-11T21:21:01Z","updated_at":"2017-10-11T21:21:01Z","author_association":"NONE","body":"In my case, I'm not doing any type of casting.  The ordering line looks like this, where the \"Id\" property is of type Int32:\r\n\r\n```\r\nrecordsQuery = recordsQuery.OrderBy(ar => ar.Id);\r\n```"}}
{"actor":{"display_login":"joshmouch"}}