-
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.
Adding support for owned types mapped to same table as well as differ…
…ent tables Fix to #26451 - Temporal Table: Owned Entities support Fix to #26469 - Query: enable temporal tables for table splitting scenarios Fix to #26705 - Query: model building for temporal table with explicitly defined period columns could fail if conventions are executed in a delayed fashion Just like any other nav expansion, this only works for AsOf operation. Added extensibility point to SharedTypeEntityExpandingExpressionVisitor so that we can create temporal table expressions representing owned entities, if their owner is also a temporal table expression. We also need to match TableExpression information with ITable metadata, for provider specific table-like expressions. Relaxed validation for table splitting when the table is temporal - it's now allowed as long as all (base type) entities mapped to this table have congruent period and history table mappings. Column period property is now created explicitly in the temporal table builder rather than relying on conventions to avoid scenario when conventions are delayed and the period property they are supposed to create is not ready by the time we need it.
- Loading branch information
Showing
19 changed files
with
2,513 additions
and
76 deletions.
There are no files selected for viewing
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
40 changes: 40 additions & 0 deletions
40
src/EFCore.Relational/Query/IRelationalSharedTypeEntityExpansionHelper.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,40 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Collections.Generic; | ||
using Microsoft.EntityFrameworkCore.Metadata; | ||
using Microsoft.EntityFrameworkCore.Query.SqlExpressions; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Query | ||
{ | ||
/// <summary> | ||
/// Service which helps with various aspects of shared type entity expansion extensibility for relational providrers. | ||
/// </summary> | ||
/// <para> | ||
/// The service lifetime is <see cref="ServiceLifetime.Scoped" />. This means that each | ||
/// <see cref="DbContext" /> instance will use its own instance of this service. | ||
/// The implementation may depend on other services registered with any lifetime. | ||
/// The implementation does not need to be thread-safe. | ||
/// </para> | ||
/// <remarks> | ||
/// See <see href="https://aka.ms/efcore-docs-providers">Implementation of database providers and extensions</see> | ||
/// and <see href="https://aka.ms/efcore-how-queries-work">How EF Core queries work</see> for more information. | ||
/// </remarks> | ||
public interface IRelationalSharedTypeEntityExpansionHelper | ||
{ | ||
/// <summary> | ||
/// Creates a SelectExpression representing owned type. | ||
/// </summary> | ||
public SelectExpression CreateInnerSelectExpression( | ||
TableExpressionBase sourceTable, | ||
IEntityType targetEntityType); | ||
|
||
/// <summary> | ||
/// Returns true if the given table expression matches table metadata, false otherwise. | ||
/// </summary> | ||
public bool TableMatchesMetadata( | ||
TableExpressionBase tableExpression, | ||
ITableBase tableMetadata); | ||
} | ||
} |
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
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
38 changes: 38 additions & 0 deletions
38
src/EFCore.Relational/Query/RelationalSharedTypeEntityExpansionHelper.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,38 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Microsoft.EntityFrameworkCore.Metadata; | ||
using Microsoft.EntityFrameworkCore.Query.SqlExpressions; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Query | ||
{ | ||
/// <inheritdoc/> | ||
public class RelationalSharedTypeEntityExpansionHelper : IRelationalSharedTypeEntityExpansionHelper | ||
{ | ||
/// <summary> | ||
/// Creates a new instance of the <see cref="RelationalSharedTypeEntityExpansionHelper" /> class. | ||
/// </summary> | ||
/// <param name="dependencies">Dependencies for this service.</param> | ||
public RelationalSharedTypeEntityExpansionHelper(RelationalSharedTypeEntityExpansionHelperDependencies dependencies) | ||
{ | ||
Dependencies = dependencies; | ||
} | ||
|
||
/// <summary> | ||
/// Dependencies for this service. | ||
/// </summary> | ||
protected virtual RelationalSharedTypeEntityExpansionHelperDependencies Dependencies { get; } | ||
|
||
/// <inheritdoc/> | ||
public virtual SelectExpression CreateInnerSelectExpression( | ||
TableExpressionBase sourceTable, | ||
IEntityType targetEntityType) | ||
=> Dependencies.SqlExpressionFactory.Select(targetEntityType); | ||
|
||
/// <inheritdoc/> | ||
public virtual bool TableMatchesMetadata(TableExpressionBase tableExpression, ITableBase tableMetadata) | ||
=> tableExpression is TableExpression table | ||
&& table.Name == tableMetadata.Name | ||
&& table.Schema == tableMetadata.Schema; | ||
} | ||
} |
Oops, something went wrong.