Skip to content

Commit 099b2a9

Browse files
rojiAndriySvyryd
andauthored
Implement stored procedure update mapping (#28553)
* Remove transaction suppression metadata * Implement stored procedure update mapping Closes #245 Closes #28435 Co-authored-by: Andriy Svyryd <[email protected]> Co-authored-by: Andriy Svyryd <[email protected]>
1 parent ba92471 commit 099b2a9

File tree

88 files changed

+2737
-703
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+2737
-703
lines changed

src/EFCore.Relational/Design/Internal/RelationalCSharpRuntimeAnnotationCodeGenerator.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,7 @@ private void Create(IStoredProcedure storedProcedure, string sprocVariable, CSha
491491
.Append(parameters.TargetName).AppendLine(",")
492492
.Append(code.Literal(storedProcedure.Name)).AppendLine(",")
493493
.Append(code.Literal(storedProcedure.Schema)).AppendLine(",")
494-
.Append(code.Literal(storedProcedure.IsRowsAffectedReturned)).AppendLine(",")
495-
.Append(code.Literal(storedProcedure.AreTransactionsSuppressed))
494+
.Append(code.Literal(storedProcedure.IsRowsAffectedReturned))
496495
.AppendLine(");")
497496
.DecrementIndent()
498497
.AppendLine();

src/EFCore.Relational/Extensions/RelationalPropertyExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ private static bool IsOptionalSharingDependent(
11531153

11541154
return optional ?? (entityType.BaseType != null && entityType.FindDiscriminatorProperty() != null);
11551155
}
1156-
1156+
11571157
/// <summary>
11581158
/// Returns the comment for the column this property is mapped to.
11591159
/// </summary>

src/EFCore.Relational/Infrastructure/RelationalModelValidator.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,16 @@ private static void ValidateSproc(IStoredProcedure sproc, string mappingStrategy
361361
_ => new Dictionary<string, IProperty>()
362362
};
363363

364+
if (mappingStrategy == RelationalAnnotationNames.TptMappingStrategy
365+
&& storeObjectIdentifier.StoreObjectType == StoreObjectType.InsertStoredProcedure
366+
&& entityType.BaseType?.GetInsertStoredProcedure() != null)
367+
{
368+
foreach (var property in primaryKey.Properties)
369+
{
370+
storeGeneratedProperties.Remove(property.Name);
371+
}
372+
}
373+
364374
var resultColumnNames = new HashSet<string>();
365375
foreach (var resultColumn in sproc.ResultColumns)
366376
{

src/EFCore.Relational/Metadata/Builders/IConventionStoredProcedureBuilder.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -156,20 +156,4 @@ public interface IConventionStoredProcedureBuilder : IConventionAnnotatableBuild
156156
/// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
157157
/// <returns><see langword="true" /> if the column of the result can be used for the stored procedure.</returns>
158158
bool CanHaveRowsAffectedResultColumn(string propertyName, bool fromDataAnnotation = false);
159-
160-
/// <summary>
161-
/// Prevents automatically creating a transaction when executing this stored procedure.
162-
/// </summary>
163-
/// <param name="suppress">A value indicating whether the automatic transactions should be prevented.</param>
164-
/// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
165-
/// <returns>The same builder instance so that multiple configuration calls can be chained.</returns>
166-
IConventionStoredProcedureBuilder? SuppressTransactions(bool suppress, bool fromDataAnnotation = false);
167-
168-
/// <summary>
169-
/// Returns a value indicating whether the transaction suppression can be set for stored procedure.
170-
/// </summary>
171-
/// <param name="suppress">A value indicating whether the automatic transactions should be prevented.</param>
172-
/// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param>
173-
/// <returns><see langword="true" /> if the column of the result can be used for the stored procedure.</returns>
174-
bool CanSetSuppressTransactions(bool suppress, bool fromDataAnnotation = false);
175159
}

src/EFCore.Relational/Metadata/Builders/OwnedNavigationStoredProcedureBuilder.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -219,17 +219,6 @@ public virtual OwnedNavigationStoredProcedureBuilder HasRowsAffectedReturnValue(
219219
return this;
220220
}
221221

222-
/// <summary>
223-
/// Prevents automatically creating a transaction when executing this stored procedure.
224-
/// </summary>
225-
/// <param name="suppress">A value indicating whether the automatic transactions should be prevented.</param>
226-
/// <returns>The same builder instance so that multiple configuration calls can be chained.</returns>
227-
public virtual OwnedNavigationStoredProcedureBuilder SuppressTransactions(bool suppress = true)
228-
{
229-
Builder.SuppressTransactions(suppress, ConfigurationSource.Explicit);
230-
return this;
231-
}
232-
233222
/// <summary>
234223
/// Adds or updates an annotation on the stored procedure. If an annotation with the key specified in
235224
/// <paramref name="annotation" /> already exists, its value will be updated.

src/EFCore.Relational/Metadata/Builders/OwnedNavigationStoredProcedureBuilder``.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,6 @@ public virtual OwnedNavigationStoredProcedureBuilder<TOwnerEntity, TDependentEnt
231231
public new virtual OwnedNavigationStoredProcedureBuilder<TOwnerEntity, TDependentEntity> HasRowsAffectedReturnValue(bool rowsAffectedReturned = true)
232232
=> (OwnedNavigationStoredProcedureBuilder<TOwnerEntity, TDependentEntity>)base.HasRowsAffectedReturnValue(rowsAffectedReturned);
233233

234-
/// <summary>
235-
/// Prevents automatically creating a transaction when executing this stored procedure.
236-
/// </summary>
237-
/// <param name="suppress">A value indicating whether the automatic transactions should be prevented.</param>
238-
/// <returns>The same builder instance so that multiple configuration calls can be chained.</returns>
239-
public new virtual OwnedNavigationStoredProcedureBuilder<TOwnerEntity, TDependentEntity> SuppressTransactions(bool suppress = true)
240-
=> (OwnedNavigationStoredProcedureBuilder<TOwnerEntity, TDependentEntity>)base.SuppressTransactions(suppress);
241-
242234
/// <summary>
243235
/// Adds or updates an annotation on the stored procedure. If an annotation with the key specified in
244236
/// <paramref name="annotation" /> already exists, its value will be updated.

src/EFCore.Relational/Metadata/Builders/StoredProcedureBuilder.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -182,17 +182,6 @@ public virtual StoredProcedureBuilder HasRowsAffectedReturnValue(bool rowsAffect
182182
return this;
183183
}
184184

185-
/// <summary>
186-
/// Prevents automatically creating a transaction when executing this stored procedure.
187-
/// </summary>
188-
/// <param name="suppress">A value indicating whether the automatic transactions should be prevented.</param>
189-
/// <returns>The same builder instance so that multiple configuration calls can be chained.</returns>
190-
public virtual StoredProcedureBuilder SuppressTransactions(bool suppress = true)
191-
{
192-
Builder.SuppressTransactions(suppress, ConfigurationSource.Explicit);
193-
return this;
194-
}
195-
196185
/// <summary>
197186
/// Adds or updates an annotation on the stored procedure. If an annotation with the key specified in
198187
/// <paramref name="annotation" /> already exists, its value will be updated.

src/EFCore.Relational/Metadata/Builders/StoredProcedureBuilder`.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -314,14 +314,6 @@ public virtual StoredProcedureBuilder<TEntity> HasResultColumn<TDerivedEntity, T
314314
public new virtual StoredProcedureBuilder<TEntity> HasRowsAffectedReturnValue(bool rowsAffectedReturned = true)
315315
=> (StoredProcedureBuilder<TEntity>)base.HasRowsAffectedReturnValue(rowsAffectedReturned);
316316

317-
/// <summary>
318-
/// Prevents automatically creating a transaction when executing this stored procedure.
319-
/// </summary>
320-
/// <param name="suppress">A value indicating whether the automatic transactions should be prevented.</param>
321-
/// <returns>The same builder instance so that multiple configuration calls can be chained.</returns>
322-
public new virtual StoredProcedureBuilder<TEntity> SuppressTransactions(bool suppress = true)
323-
=> (StoredProcedureBuilder<TEntity>)base.SuppressTransactions(suppress);
324-
325317
/// <summary>
326318
/// Adds or updates an annotation on the stored procedure. If an annotation with the key specified in
327319
/// <paramref name="annotation" /> already exists, its value will be updated.

src/EFCore.Relational/Metadata/Conventions/RelationalRuntimeModelConvention.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,7 @@ private RuntimeStoredProcedure Create(IStoredProcedure storedProcedure, RuntimeE
498498
runtimeEntityType,
499499
storedProcedure.Name,
500500
storedProcedure.Schema,
501-
storedProcedure.IsRowsAffectedReturned,
502-
storedProcedure.AreTransactionsSuppressed);
501+
storedProcedure.IsRowsAffectedReturned);
503502

504503
foreach (var parameter in storedProcedure.Parameters)
505504
{

src/EFCore.Relational/Metadata/IColumn.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,6 @@ bool TryGetDefaultValue(out object? defaultValue)
147147
=> PropertyMappings.First().Property
148148
.GetCollation(StoreObjectIdentifier.Table(Table.Name, Table.Schema));
149149

150-
/// <summary>
151-
/// Gets the <see cref="ValueComparer" /> for this column.
152-
/// </summary>
153-
/// <returns>The comparer.</returns>
154-
ValueComparer ProviderValueComparer
155-
=> PropertyMappings.First().Property
156-
.GetProviderValueComparer();
157-
158150
/// <summary>
159151
/// Returns the property mapping for the given entity type.
160152
/// </summary>

0 commit comments

Comments
 (0)