Skip to content

Commit

Permalink
Remove transaction suppression metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
roji committed Aug 9, 2022
1 parent 630edd1 commit 0cdbd54
Show file tree
Hide file tree
Showing 15 changed files with 33 additions and 234 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,6 @@ private void Create(IStoredProcedure storedProcedure, string sprocVariable, CSha
.Append(code.Literal(storedProcedure.Name)).AppendLine(",")
.Append(code.Literal(storedProcedure.Schema)).AppendLine(",")
.Append(code.Literal(storedProcedure.IsRowsAffectedReturned)).AppendLine(",")
.Append(code.Literal(storedProcedure.AreTransactionsSuppressed))
.AppendLine(");")
.DecrementIndent()
.AppendLine();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,20 +156,4 @@ public interface IConventionStoredProcedureBuilder : IConventionAnnotatableBuild
/// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
/// <returns><see langword="true" /> if the column of the result can be used for the stored procedure.</returns>
bool CanHaveRowsAffectedResultColumn(string propertyName, bool fromDataAnnotation = false);

/// <summary>
/// Prevents automatically creating a transaction when executing this stored procedure.
/// </summary>
/// <param name="suppress">A value indicating whether the automatic transactions should be prevented.</param>
/// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
/// <returns>The same builder instance so that multiple configuration calls can be chained.</returns>
IConventionStoredProcedureBuilder? SuppressTransactions(bool suppress, bool fromDataAnnotation = false);

/// <summary>
/// Returns a value indicating whether the transaction suppression can be set for stored procedure.
/// </summary>
/// <param name="suppress">A value indicating whether the automatic transactions should be prevented.</param>
/// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
/// <returns><see langword="true" /> if the column of the result can be used for the stored procedure.</returns>
bool CanSetSuppressTransactions(bool suppress, bool fromDataAnnotation = false);
}
Original file line number Diff line number Diff line change
Expand Up @@ -219,17 +219,6 @@ public virtual OwnedNavigationStoredProcedureBuilder HasRowsAffectedReturnValue(
return this;
}

/// <summary>
/// Prevents automatically creating a transaction when executing this stored procedure.
/// </summary>
/// <param name="suppress">A value indicating whether the automatic transactions should be prevented.</param>
/// <returns>The same builder instance so that multiple configuration calls can be chained.</returns>
public virtual OwnedNavigationStoredProcedureBuilder SuppressTransactions(bool suppress = true)
{
Builder.SuppressTransactions(suppress, ConfigurationSource.Explicit);
return this;
}

/// <summary>
/// Adds or updates an annotation on the stored procedure. If an annotation with the key specified in
/// <paramref name="annotation" /> already exists, its value will be updated.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,6 @@ public virtual OwnedNavigationStoredProcedureBuilder<TOwnerEntity, TDependentEnt
public new virtual OwnedNavigationStoredProcedureBuilder<TOwnerEntity, TDependentEntity> HasRowsAffectedReturnValue(bool rowsAffectedReturned = true)
=> (OwnedNavigationStoredProcedureBuilder<TOwnerEntity, TDependentEntity>)base.HasRowsAffectedReturnValue(rowsAffectedReturned);

/// <summary>
/// Prevents automatically creating a transaction when executing this stored procedure.
/// </summary>
/// <param name="suppress">A value indicating whether the automatic transactions should be prevented.</param>
/// <returns>The same builder instance so that multiple configuration calls can be chained.</returns>
public new virtual OwnedNavigationStoredProcedureBuilder<TOwnerEntity, TDependentEntity> SuppressTransactions(bool suppress = true)
=> (OwnedNavigationStoredProcedureBuilder<TOwnerEntity, TDependentEntity>)base.SuppressTransactions(suppress);

/// <summary>
/// Adds or updates an annotation on the stored procedure. If an annotation with the key specified in
/// <paramref name="annotation" /> already exists, its value will be updated.
Expand Down
11 changes: 0 additions & 11 deletions src/EFCore.Relational/Metadata/Builders/StoredProcedureBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,6 @@ public virtual StoredProcedureBuilder HasRowsAffectedReturnValue(bool rowsAffect
return this;
}

/// <summary>
/// Prevents automatically creating a transaction when executing this stored procedure.
/// </summary>
/// <param name="suppress">A value indicating whether the automatic transactions should be prevented.</param>
/// <returns>The same builder instance so that multiple configuration calls can be chained.</returns>
public virtual StoredProcedureBuilder SuppressTransactions(bool suppress = true)
{
Builder.SuppressTransactions(suppress, ConfigurationSource.Explicit);
return this;
}

/// <summary>
/// Adds or updates an annotation on the stored procedure. If an annotation with the key specified in
/// <paramref name="annotation" /> already exists, its value will be updated.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,6 @@ public virtual StoredProcedureBuilder<TEntity> HasResultColumn<TDerivedEntity, T
public new virtual StoredProcedureBuilder<TEntity> HasRowsAffectedReturnValue(bool rowsAffectedReturned = true)
=> (StoredProcedureBuilder<TEntity>)base.HasRowsAffectedReturnValue(rowsAffectedReturned);

/// <summary>
/// Prevents automatically creating a transaction when executing this stored procedure.
/// </summary>
/// <param name="suppress">A value indicating whether the automatic transactions should be prevented.</param>
/// <returns>The same builder instance so that multiple configuration calls can be chained.</returns>
public new virtual StoredProcedureBuilder<TEntity> SuppressTransactions(bool suppress = true)
=> (StoredProcedureBuilder<TEntity>)base.SuppressTransactions(suppress);

/// <summary>
/// Adds or updates an annotation on the stored procedure. If an annotation with the key specified in
/// <paramref name="annotation" /> already exists, its value will be updated.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,8 +498,7 @@ private RuntimeStoredProcedure Create(IStoredProcedure storedProcedure, RuntimeE
runtimeEntityType,
storedProcedure.Name,
storedProcedure.Schema,
storedProcedure.IsRowsAffectedReturned,
storedProcedure.AreTransactionsSuppressed);
storedProcedure.IsRowsAffectedReturned);

foreach (var parameter in storedProcedure.Parameters)
{
Expand Down
14 changes: 0 additions & 14 deletions src/EFCore.Relational/Metadata/IConventionStoredProcedure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,4 @@ public interface IConventionStoredProcedure : IReadOnlyStoredProcedure, IConvent
/// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
/// <returns>The configured value.</returns>
bool SetIsRowsAffectedReturned(bool rowsAffectedReturned, bool fromDataAnnotation = false);

/// <summary>
/// Prevents automatically creating a transaction when executing this stored procedure.
/// </summary>
/// <param name="areTransactionsSuppressed">A value indicating whether the automatic transactions should be prevented.</param>
/// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
/// <returns>The configured value.</returns>
bool SetAreTransactionsSuppressed(bool areTransactionsSuppressed, bool fromDataAnnotation = false);

/// <summary>
/// Gets the configuration source for <see cref="IReadOnlyStoredProcedure.Schema" />.
/// </summary>
/// <returns>The configuration source for <see cref="IReadOnlyStoredProcedure.Schema" />.</returns>
ConfigurationSource? GetAreTransactionsSuppressedConfigurationSource();
}
6 changes: 0 additions & 6 deletions src/EFCore.Relational/Metadata/IMutableStoredProcedure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ public interface IMutableStoredProcedure : IReadOnlyStoredProcedure, IMutableAnn
/// </summary>
new IMutableEntityType EntityType { get; }

/// <summary>
/// Returns a value indicating whether automatic creation of transactions is disabled when executing this stored procedure.
/// </summary>
/// <returns>The configured value.</returns>
new bool AreTransactionsSuppressed { get; set; }

/// <summary>
/// Gets or sets a value indicating whether this stored procedure returns the number of rows affected.
/// </summary>
Expand Down
5 changes: 0 additions & 5 deletions src/EFCore.Relational/Metadata/IReadOnlyStoredProcedure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ public interface IReadOnlyStoredProcedure : IReadOnlyAnnotatable
/// </summary>
IReadOnlyEntityType EntityType { get; }

/// <summary>
/// Returns a value indicating whether automatic creation of transactions is disabled when executing this stored procedure.
/// </summary>
bool AreTransactionsSuppressed { get; }

/// <summary>
/// Gets a value indicating whether this stored procedure returns the number of rows affected.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,33 +410,6 @@ public virtual bool CanHaveRowsAffectedReturn(bool rowsAffectedReturned, Configu
=> Metadata.IsRowsAffectedReturned == rowsAffectedReturned
|| configurationSource.Overrides(Metadata.GetConfigurationSource());

/// <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 virtual InternalStoredProcedureBuilder? SuppressTransactions(bool suppress, ConfigurationSource configurationSource)
{
if (!CanSuppressTransactions(suppress, configurationSource))
{
return null;
}

Metadata.SetAreTransactionsSuppressed(suppress, configurationSource);
return this;
}

/// <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 virtual bool CanSuppressTransactions(bool suppress, ConfigurationSource configurationSource)
=> Metadata.AreTransactionsSuppressed == suppress
|| configurationSource.Overrides(Metadata.GetAreTransactionsSuppressedConfigurationSource());

IConventionStoredProcedure IConventionStoredProcedureBuilder.Metadata
{
[DebuggerStepThrough]
Expand Down Expand Up @@ -524,15 +497,4 @@ bool IConventionStoredProcedureBuilder.CanHaveResultColumn(string propertyName,
[DebuggerStepThrough]
bool IConventionStoredProcedureBuilder.CanHaveRowsAffectedResultColumn(string propertyName, bool fromDataAnnotation)
=> CanHaveRowsAffectedResultColumn(fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);

/// <inheritdoc />
[DebuggerStepThrough]
IConventionStoredProcedureBuilder? IConventionStoredProcedureBuilder.SuppressTransactions(bool suppress, bool fromDataAnnotation)
=> SuppressTransactions(suppress, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);

/// <inheritdoc />
[DebuggerStepThrough]
bool IConventionStoredProcedureBuilder.CanSetSuppressTransactions(bool suppress, bool fromDataAnnotation)
=> CanSuppressTransactions(suppress,
fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);
}
43 changes: 1 addition & 42 deletions src/EFCore.Relational/Metadata/Internal/StoredProcedure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ public class StoredProcedure :
private string? _schema;
private string? _name;
private InternalStoredProcedureBuilder? _builder;
private bool _areTransactionsSuppressed;
private bool _isRowsAffectedReturned;
private IStoreStoredProcedure? _storeStoredProcedure;

private ConfigurationSource _configurationSource;
private ConfigurationSource? _schemaConfigurationSource;
private ConfigurationSource? _nameConfigurationSource;
private ConfigurationSource? _areTransactionsSuppressedConfigurationSource;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down Expand Up @@ -442,30 +440,6 @@ public virtual void SetName(string? name, string? schema, ConfigurationSource co
public virtual ConfigurationSource? GetNameConfigurationSource()
=> _nameConfigurationSource;

/// <inheritdoc />
public virtual bool AreTransactionsSuppressed
{
get => _areTransactionsSuppressed;
set => SetAreTransactionsSuppressed(value, ConfigurationSource.Explicit);
}

/// <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 virtual bool SetAreTransactionsSuppressed(bool areTransactionsSuppressed, ConfigurationSource configurationSource)
{
EnsureMutable();

_areTransactionsSuppressed = areTransactionsSuppressed;

_areTransactionsSuppressedConfigurationSource = configurationSource.Max(_areTransactionsSuppressedConfigurationSource);

return areTransactionsSuppressed;
}

/// <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
Expand Down Expand Up @@ -498,15 +472,6 @@ public virtual bool SetIsRowsAffectedReturned(bool rowsAffectedReturned)

return rowsAffectedReturned;
}

/// <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 virtual ConfigurationSource? GetAreTransactionsSuppressedConfigurationSource()
=> _areTransactionsSuppressedConfigurationSource;

private static void UpdateOverrides(
StoreObjectIdentifier oldId,
Expand Down Expand Up @@ -851,17 +816,11 @@ IReadOnlyList<IStoredProcedureResultColumn> IStoredProcedure.ResultColumns
string? IConventionStoredProcedure.SetSchema(string? schema, bool fromDataAnnotation)
=> SetSchema(schema, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);

/// <inheritdoc />
[DebuggerStepThrough]
bool IConventionStoredProcedure.SetAreTransactionsSuppressed(bool areTransactionsSuppressed, bool fromDataAnnotation)
=> SetAreTransactionsSuppressed(
areTransactionsSuppressed, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention);

/// <inheritdoc />
[DebuggerStepThrough]
bool IConventionStoredProcedure.SetIsRowsAffectedReturned(bool rowsAffectedReturned, bool fromDataAnnotation)
=> SetIsRowsAffectedReturned(rowsAffectedReturned);

/// <inheritdoc />
[DebuggerStepThrough]
IReadOnlyStoredProcedureParameter? IReadOnlyStoredProcedure.FindParameter(string propertyName)
Expand Down
13 changes: 1 addition & 12 deletions src/EFCore.Relational/Metadata/RuntimeStoredProcedure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class RuntimeStoredProcedure : AnnotatableBase, IRuntimeStoredProcedure
private readonly string? _schema;
private readonly string _name;
private readonly bool _isRowsAffectedReturned;
private readonly bool _areTransactionsSuppressed;
private IStoreStoredProcedure? _storeStoredProcedure;

/// <summary>
Expand All @@ -29,19 +28,16 @@ public class RuntimeStoredProcedure : AnnotatableBase, IRuntimeStoredProcedure
/// <param name="name">The name.</param>
/// <param name="schema">The schema.</param>
/// <param name="rowsAffectedReturned">Whether this stored procedure returns the number of rows affected.</param>
/// <param name="transactionsSuppressed">Whether the automatic transactions are surpressed.</param>
public RuntimeStoredProcedure(
RuntimeEntityType entityType,
string name,
string? schema,
bool rowsAffectedReturned,
bool transactionsSuppressed)
bool rowsAffectedReturned)
{
EntityType = entityType;
_name = name;
_schema = schema;
_isRowsAffectedReturned = rowsAffectedReturned;
_areTransactionsSuppressed = transactionsSuppressed;
}

/// <summary>
Expand Down Expand Up @@ -151,13 +147,6 @@ string IStoredProcedure.Name
get => _schema;
}

/// <inheritdoc />
bool IReadOnlyStoredProcedure.AreTransactionsSuppressed
{
[DebuggerStepThrough]
get => _areTransactionsSuppressed;
}

/// <inheritdoc />
bool IReadOnlyStoredProcedure.IsRowsAffectedReturned
{
Expand Down
Loading

0 comments on commit 0cdbd54

Please sign in to comment.