-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix to #31365 - Query: add support for projecting JSON entities that …
…have been composed on Adding new materialization path for JSON entities that have been converted to query roots - they look like normal entity, but materialization is somewhat different. We need to prune synthesized key properties from materializer code (as they are not associated with any column, but rather made up on the fly) Also added code to include all the child navigations. For normal entities we have IncludeExpressions in the shaper expression, but for JSON we prune all includes and build them in the materializer. Fix is to recognize the scenario (entity projection but the entity is mapped to JSON) during apply projection phase and generate all the necessary info needed rather than just dictionary of property to index maps like we do for regular entity. Then when we build materializer we use that info to prune the synthesized properties from key check and re-use existing include JSON entity code to add child navigations. Fixes #31365
- Loading branch information
Showing
8 changed files
with
696 additions
and
68 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
src/EFCore.Relational/Query/Internal/QueryableJsonProjectionInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace Microsoft.EntityFrameworkCore.Query.Internal; | ||
|
||
/// <summary> | ||
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to | ||
/// the same compatibility standards as public APIs. It may be changed or removed without notice in | ||
/// any release. You should only use it directly in your code with extreme caution and knowing that | ||
/// doing so can result in application failures when updating to a new Entity Framework Core release. | ||
/// </summary> | ||
public readonly struct QueryableJsonProjectionInfo | ||
{ | ||
/// <summary> | ||
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to | ||
/// the same compatibility standards as public APIs. It may be changed or removed without notice in | ||
/// any release. You should only use it directly in your code with extreme caution and knowing that | ||
/// doing so can result in application failures when updating to a new Entity Framework Core release. | ||
/// </summary> | ||
public QueryableJsonProjectionInfo( | ||
Dictionary<IProperty, int> propertyIndexMap, | ||
List<(JsonProjectionInfo, INavigation)> childrenProjectionInfo) | ||
{ | ||
PropertyIndexMap = propertyIndexMap; | ||
ChildrenProjectionInfo = childrenProjectionInfo; | ||
} | ||
|
||
/// <summary> | ||
/// Map between entity properties and corresponding column indexes. | ||
/// </summary> | ||
/// <remarks> | ||
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to | ||
/// the same compatibility standards as public APIs. It may be changed or removed without notice in | ||
/// any release. You should only use it directly in your code with extreme caution and knowing that | ||
/// doing so can result in application failures when updating to a new Entity Framework Core release. | ||
/// </remarks> | ||
public IDictionary<IProperty, int> PropertyIndexMap { get; } | ||
|
||
/// <summary> | ||
/// Information needed to construct each child JSON entity. | ||
/// - JsonProjection info (same one we use for simple JSON projection), | ||
/// - navigation between parent and the child JSON entity. | ||
/// </summary> | ||
/// <remarks> | ||
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to | ||
/// the same compatibility standards as public APIs. It may be changed or removed without notice in | ||
/// any release. You should only use it directly in your code with extreme caution and knowing that | ||
/// doing so can result in application failures when updating to a new Entity Framework Core release. | ||
/// </remarks> | ||
public IList<(JsonProjectionInfo JsonProjectionInfo, INavigation Navigation)> ChildrenProjectionInfo { get; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.