-
Notifications
You must be signed in to change notification settings - Fork 3.3k
ClrCollectionAccessor cleanup for complex JSON collections #36618
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
base: release/10.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
using System.Runtime.CompilerServices; | ||
using System.Text.Json; | ||
using Microsoft.EntityFrameworkCore.Internal; | ||
using Microsoft.EntityFrameworkCore.Metadata.Internal; | ||
using Microsoft.EntityFrameworkCore.Query.Internal; | ||
using Microsoft.EntityFrameworkCore.Storage.Json; | ||
|
||
|
@@ -1076,8 +1077,12 @@ static async Task<RelationalDataReader> InitializeReaderAsync( | |
throw new InvalidOperationException(CoreStrings.JsonReaderInvalidTokenType(tokenType.ToString())); | ||
} | ||
|
||
var collectionAccessor = relationship.GetCollectionAccessor(); | ||
var result = (TResult)collectionAccessor!.Create(); | ||
// var collectionAccessor = relationship.GetCollectionAccessor(); | ||
#pragma warning disable EF1001 // Internal EF Core API usage. | ||
var collectionAccessor = ((IRuntimePropertyBase)relationship).GetIndexedCollectionAccessor(); | ||
#pragma warning restore EF1001 // Internal EF Core API usage. | ||
|
||
var result = (TResult)collectionAccessor!.Create(0); | ||
|
||
object[]? newKeyPropertyValues = null; | ||
|
||
|
@@ -1098,7 +1103,7 @@ static async Task<RelationalDataReader> InitializeReaderAsync( | |
{ | ||
manager.CaptureState(); | ||
var entity = innerShaper(queryContext, newKeyPropertyValues, jsonReaderData); | ||
collectionAccessor.AddStandalone(result, entity); | ||
// collectionAccessor.AddStandalone(result, entity); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have no idea what this means (yet) but it doesn't exist on ClrIndexedCollectionAccessor. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It allows to add an element to the collection without the containing object. We could add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, |
||
manager = new Utf8JsonReaderManager(manager.Data, queryContext.QueryLogger); | ||
|
||
if (manager.CurrentReader.TokenType != JsonTokenType.EndObject) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GetIndexedCollectionAccessor() is only available on IRuntimePropertyBase (unlike GetCollectionAccessor() which is available on IPropertyBase). I don't have strong feelings here but maybe seems like they should be consistent?
Also note that GetIndexedCollectionAccessor is pubternal (another thing to maybe change).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is pubternal until we are satisfied with the API