-
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.
- Loading branch information
Showing
7 changed files
with
163 additions
and
29 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
53 changes: 53 additions & 0 deletions
53
src/EFCore.SqlServer/Extensions/SqlServerEntityTypeMappingFragmentExtensions.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,53 @@ | ||
// 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.SqlServer.Metadata.Internal; | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace Microsoft.EntityFrameworkCore; | ||
|
||
/// <summary> | ||
/// SQL Server specific extension methods for <see cref="IReadOnlyEntityTypeMappingFragment" />. | ||
/// </summary> | ||
public static class SqlServerEntityTypeMappingFragmentExtensions | ||
{ | ||
/// <summary> | ||
/// Returns a value indicating whether to use the SQL OUTPUT clause when saving changes to the associated table. | ||
/// The OUTPUT clause is incompatible with certain SQL Server features, such as tables with triggers. | ||
/// </summary> | ||
/// <param name="fragment">The entity type mapping fragment.</param> | ||
/// <returns>The configured value.</returns> | ||
public static bool? IsSqlOutputClauseUsed(this IReadOnlyEntityTypeMappingFragment fragment) | ||
=> fragment.FindAnnotation(SqlServerAnnotationNames.UseSqlOutputClause) is not { Value: false }; | ||
|
||
/// <summary> | ||
/// Sets whether to use the SQL OUTPUT clause when saving changes to the associated table. | ||
/// The OUTPUT clause is incompatible with certain SQL Server features, such as tables with triggers. | ||
/// </summary> | ||
/// <param name="fragment">The entity type mapping fragment.</param> | ||
/// <param name="useSqlOutputClause">The value to set.</param> | ||
public static void UseSqlOutputClause(this IMutableEntityTypeMappingFragment fragment, bool? useSqlOutputClause) | ||
=> fragment.SetAnnotation(SqlServerAnnotationNames.UseSqlOutputClause, useSqlOutputClause); | ||
|
||
/// <summary> | ||
/// Sets whether to use the SQL OUTPUT clause when saving changes to the associated table. | ||
/// The OUTPUT clause is incompatible with certain SQL Server features, such as tables with triggers. | ||
/// </summary> | ||
/// <param name="fragment">The entity type mapping fragment.</param> | ||
/// <param name="useSqlOutputClause">The value to set.</param> | ||
/// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param> | ||
/// <returns>A value indicating whether the SQL OUTPUT clause is used to save changes to the associated table.</returns> | ||
public static bool? UseSqlOutputClause( | ||
this IConventionEntityTypeMappingFragment fragment, | ||
bool? useSqlOutputClause, | ||
bool fromDataAnnotation = false) | ||
=> (bool?)fragment.SetAnnotation(SqlServerAnnotationNames.UseSqlOutputClause, useSqlOutputClause, fromDataAnnotation)?.Value; | ||
|
||
/// <summary> | ||
/// Gets the configuration source for the setting whether to use the SQL OUTPUT clause when saving changes to the associated table. | ||
/// </summary> | ||
/// <param name="fragment">The entity type mapping fragment.</param> | ||
/// <returns>The configuration source for the temporal history table schema setting.</returns> | ||
public static ConfigurationSource? GetUseSqlOutputClauseConfigurationSource(this IConventionEntityTypeMappingFragment fragment) | ||
=> fragment.FindAnnotation(SqlServerAnnotationNames.UseSqlOutputClause)?.GetConfigurationSource(); | ||
} |
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
20 changes: 20 additions & 0 deletions
20
src/EFCore.SqlServer/Extensions/SqlServerTableExtensions.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,20 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace Microsoft.EntityFrameworkCore; | ||
|
||
/// <summary> | ||
/// SQL Server specific extension methods for <see cref="ITable" />. | ||
/// </summary> | ||
public static class SqlServerTableExtensions | ||
{ | ||
/// <summary> | ||
/// Returns a value indicating whether to use the SQL OUTPUT clause when saving changes to the table. The OUTPUT clause is | ||
/// incompatible with certain SQL Server features, such as tables with triggers. | ||
/// </summary> | ||
/// <param name="table">The table.</param> | ||
/// <returns><see langword="true" /> if the SQL OUTPUT clause is used to save changes to the table.</returns> | ||
public static bool IsSqlOutputClauseUsed(this ITable table) | ||
=> table.EntityTypeMappings.First().EntityType.IsSqlOutputClauseUsed(StoreObjectIdentifier.Table(table.Name, table.Schema)); | ||
} |
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
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