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

Including an inherited navigation throws IndexOutOfRangeException #6570

Closed
AndriySvyryd opened this issue Sep 19, 2016 · 0 comments
Closed
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@AndriySvyryd
Copy link
Member

AndriySvyryd commented Sep 19, 2016

See #6571 for full repro

var character = context.Characters
    .Include(c => c.Level.Game)
    .First();
System.IndexOutOfRangeException : Index was outside the bounds of the array.
    ChangeTracking\Internal\StateData.cs(73,0): at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.StateData.FlagProperty(Int32 propertyIndex, PropertyFlag propertyFlag, Boolean isFlagged)
    ChangeTracking\Internal\InternalEntityEntry.cs(1034,0): at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.SetIsLoaded(INavigation navigation, Boolean loaded)
    Query\Internal\EntityTrackingInfo.cs(218,0): at Microsoft.EntityFrameworkCore.Query.Internal.EntityTrackingInfo.<GetIncludedEntities>d__17.MoveNext()
    at System.Linq.Enumerable.<SelectManyIterator>d__16`2.MoveNext()
    at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
    Query\Internal\QueryBuffer.cs(140,0): at Microsoft.EntityFrameworkCore.Query.Internal.QueryBuffer.StartTracking(Object entity, EntityTrackingInfo entityTrackingInfo)
    Query\QueryContext.cs(136,0): at Microsoft.EntityFrameworkCore.Query.QueryContext.StartTracking(Object entity, EntityTrackingInfo entityTrackingInfo)
    Query\Internal\LinqOperatorProvider.cs(191,0): at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.<_TrackEntities>d__15`2.MoveNext()
    Query\Internal\LinqOperatorProvider.cs(145,0): at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext()
    at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
    Query\Internal\QueryCompiler.cs(200,0): at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass19_1`1.<CompileQuery>b__1(QueryContext qc)
    Query\Internal\QueryCompiler.cs(98,0): at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
    Query\Internal\EntityQueryProvider.cs(57,0): at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression)
    at System.Linq.Queryable.First[TSource](IQueryable`1 source)
    SqlServerEndToEndTest.cs(420,0): at Microsoft.EntityFrameworkCore.SqlServer.FunctionalTests.SqlServerEndToEndTest.Can_track_an_entity_with_more_than_10_properties()
AndriySvyryd added a commit that referenced this issue Sep 19, 2016
@ajcvickers ajcvickers self-assigned this Sep 19, 2016
@ajcvickers ajcvickers added this to the 1.1.0 milestone Sep 19, 2016
ajcvickers added a commit that referenced this issue Sep 19, 2016
Issues #6570

This issue is caused by incorrectly calculating the indexes for navigations. Navigations started counting at the end of the properties, but I'm not sure why that was since all uses appear to be independent. This lack of overlap was then "corrected for" when using the index for the IsLoaded flag, but this correction was done incorrectly when derived types were involved. The fix is to just make navigation indexes count independently from property indexes. Note, however, that relationship indexes are still combined.
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Sep 19, 2016
@ajcvickers ajcvickers modified the milestones: 1.1.0-preview1, 1.1.0 Oct 15, 2022
@ajcvickers ajcvickers removed their assignment Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

No branches or pull requests

2 participants