-
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 #26858 - Query: improve TableExpressionBase extensibility by a…
…dding annotations Added annotation infra for TableExpressionBase and annotations for temporal table information. Removed (now unnecessary) temporal specific table expressions. Fixes #26858
- Loading branch information
Showing
20 changed files
with
433 additions
and
439 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
80 changes: 80 additions & 0 deletions
80
src/EFCore.Relational/Query/SqlExpressions/ISqlExpressionAnnotatable.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,80 @@ | ||
// 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.SqlExpressions; | ||
|
||
/// <summary> | ||
/// <para> | ||
/// A class that exposes sql expression annotations. Annotations allow for arbitrary metadata to be stored on an object. | ||
/// </para> | ||
/// <para> | ||
/// This interface is typically used by database providers (and other extensions). It is generally | ||
/// not used in application code. | ||
/// </para> | ||
/// </summary> | ||
/// <remarks> | ||
/// See <see href="https://aka.ms/efcore-docs-providers">Implementation of database providers and extensions</see> | ||
/// for more information and examples. | ||
/// </remarks> | ||
public interface ISqlExpressionAnnotatable | ||
{ | ||
/// <summary> | ||
/// Gets the value of the annotation with the given name, returning <see langword="null" /> if it does not exist. | ||
/// </summary> | ||
/// <param name="name">The name of the annotation to find.</param> | ||
/// <returns> | ||
/// The value of the existing annotation if an annotation with the specified name already exists. Otherwise, <see langword="null" />. | ||
/// </returns> | ||
object? this[string name] { get; } | ||
|
||
/// <summary> | ||
/// Gets the annotation with the given name, returning <see langword="null" /> if it does not exist. | ||
/// </summary> | ||
/// <param name="name">The name of the annotation to find.</param> | ||
/// <returns> | ||
/// The existing annotation if an annotation with the specified name already exists. Otherwise, <see langword="null" />. | ||
/// </returns> | ||
ISqlExpressionAnnotation? FindAnnotation(string name); | ||
|
||
/// <summary> | ||
/// Gets all annotations on the current object. | ||
/// </summary> | ||
IEnumerable<ISqlExpressionAnnotation> GetAnnotations(); | ||
|
||
/// <summary> | ||
/// Removes the given annotation from this object. | ||
/// </summary> | ||
/// <param name="name">The annotation to remove.</param> | ||
/// <returns>The annotation that was removed.</returns> | ||
ISqlExpressionAnnotation? RemoveAnnotation(string name); | ||
|
||
/// <summary> | ||
/// Sets the annotation stored under the given key. Overwrites the existing annotation if an | ||
/// annotation with the specified name already exists. | ||
/// </summary> | ||
/// <param name="name">The key of the annotation to be added.</param> | ||
/// <param name="value">The value to be stored in the annotation.</param> | ||
void SetAnnotation(string name, object? value); | ||
|
||
///// <summary> | ||
///// Sets the annotation stored under the given key. Overwrites the existing annotation if an | ||
///// annotation with the specified name already exists. | ||
///// </summary> | ||
///// <param name="name">The key of the annotation to be added.</param> | ||
///// <param name="annotation">The annotation to be set.</param> | ||
///// <param name="oldAnnotation">The annotation being replaced.</param> | ||
///// <returns>The annotation that was set.</returns> | ||
//ISqlExpressionAnnotation? SetAnnotation( | ||
// string name, | ||
// ISqlExpressionAnnotation annotation, | ||
// ISqlExpressionAnnotation? oldAnnotation); | ||
|
||
///// <summary> | ||
///// Gets the annotation with the given name, throwing if it does not exist. | ||
///// </summary> | ||
///// <param name="annotationName">The key of the annotation to find.</param> | ||
///// <returns>The annotation with the specified name.</returns> | ||
//IAnnotation GetAnnotation(string annotationName) | ||
// => AnnotatableBase.GetAnnotation(this, annotationName); | ||
} | ||
|
30 changes: 30 additions & 0 deletions
30
src/EFCore.Relational/Query/SqlExpressions/ISqlExpressionAnnotation.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,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.SqlExpressions; | ||
|
||
/// <summary> | ||
/// <para> | ||
/// An arbitrary piece of metadata that can be stored on an object. | ||
/// </para> | ||
/// <para> | ||
/// This interface is typically used by database providers (and other extensions). It is generally | ||
/// not used in application code. | ||
/// </para> | ||
/// </summary> | ||
/// <remarks> | ||
/// See <see href="https://aka.ms/efcore-docs-providers">Implementation of database providers and extensions</see> | ||
/// for more information and examples. | ||
/// </remarks> | ||
public interface ISqlExpressionAnnotation | ||
{ | ||
/// <summary> | ||
/// Gets the key of this annotation. | ||
/// </summary> | ||
string Name { get; } | ||
|
||
/// <summary> | ||
/// Gets the value assigned to this annotation. | ||
/// </summary> | ||
object? Value { 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
43 changes: 43 additions & 0 deletions
43
src/EFCore.Relational/Query/SqlExpressions/SqlExpressionAnnotation.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,43 @@ | ||
// 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.SqlExpressions; | ||
|
||
/// <summary> | ||
/// <para> | ||
/// An arbitrary piece of metadata that can be stored on an object. | ||
/// </para> | ||
/// <para> | ||
/// This interface is typically used by database providers (and other extensions). It is generally | ||
/// not used in application code. | ||
/// </para> | ||
/// </summary> | ||
/// <remarks> | ||
/// See <see href="https://aka.ms/efcore-docs-providers">Implementation of database providers and extensions</see> | ||
/// for more information and examples. | ||
/// </remarks> | ||
public class SqlExpressionAnnotation : ISqlExpressionAnnotation | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="SqlExpressionAnnotation" /> class. | ||
/// </summary> | ||
/// <param name="name">The key of this annotation.</param> | ||
/// <param name="value">The value assigned to this annotation.</param> | ||
public SqlExpressionAnnotation(string name, object? value) | ||
{ | ||
Check.NotEmpty(name, nameof(name)); | ||
|
||
Name = name; | ||
Value = value; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the key of this annotation. | ||
/// </summary> | ||
public virtual string Name { get; } | ||
|
||
/// <summary> | ||
/// Gets the value assigned to this annotation. | ||
/// </summary> | ||
public virtual object? Value { 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.