-
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 #26469 - Query: enable temporal tables for table splitting sce…
…narios 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. Just like any other nav expansion, this only works for AsOf operation. Also added internal interface to TableExpression, so that we can extract table metadata information (table name and schema) from provider specific table expressions. Relaxed validation for table splitting entities mapped to temporal table - they are ok as long as their period columns are consistent.
- Loading branch information
Showing
21 changed files
with
1,886 additions
and
41 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
39 changes: 39 additions & 0 deletions
39
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,39 @@ | ||
// 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; | ||
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 <see cref="TableExpressionBase" /> related to the source table for a given entity type. | ||
/// </summary> | ||
public TableExpressionBase CreateRelatedTableExpression( | ||
TableExpressionBase sourceTable, | ||
IEntityType targetEntityType); | ||
|
||
///// <summary> | ||
///// Creates a SelectExpression representing owned type. | ||
///// </summary> | ||
//public SelectExpression CreateInnerSelectExpression( | ||
// TableExpressionBase sourceTable, | ||
// IEntityType targetEntityType); | ||
} | ||
} |
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,30 @@ | ||
// 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 interface ITableMetadata | ||
{ | ||
/// <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> | ||
string Name { get; } | ||
|
||
/// <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> | ||
string? Schema { 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
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
47 changes: 47 additions & 0 deletions
47
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,47 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Linq; | ||
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 TableExpressionBase CreateRelatedTableExpression( | ||
TableExpressionBase sourceTable, | ||
IEntityType targetEntityType) | ||
{ | ||
var table = targetEntityType.GetTableMappings().Single().Table; | ||
|
||
return new TableExpression(table); | ||
|
||
//Dependencies.SqlExpressionFactory.Select(targetEntityType) | ||
|
||
//throw new System.NotImplementedException(); | ||
} | ||
|
||
///// <inheritdoc/> | ||
//public virtual SelectExpression CreateInnerSelectExpression( | ||
// TableExpressionBase sourceTable, | ||
// IEntityType targetEntityType) | ||
// => Dependencies.SqlExpressionFactory.Select(targetEntityType); | ||
} | ||
} |
Oops, something went wrong.