forked from dotnet/efcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow opting out of RETURNING/OUTPUT clauses in SaveChanges
Fixes dotnet#29916
- Loading branch information
Showing
56 changed files
with
1,964 additions
and
213 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
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
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
8 changes: 8 additions & 0 deletions
8
src/EFCore.Relational/Properties/RelationalStrings.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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>The configured value.</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 configured value.</returns> | ||
public static ConfigurationSource? GetUseSqlOutputClauseConfigurationSource(this IConventionEntityTypeMappingFragment fragment) | ||
=> fragment.FindAnnotation(SqlServerAnnotationNames.UseSqlOutputClause)?.GetConfigurationSource(); | ||
} |
Oops, something went wrong.