Skip to content

Commit

Permalink
Query: Cleanup exception message about bulk updates
Browse files Browse the repository at this point in the history
Resolves #28737
  • Loading branch information
smitpatel committed Aug 24, 2022
1 parent dd28973 commit 257ae5d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 24 deletions.
22 changes: 10 additions & 12 deletions src/EFCore.Relational/Properties/RelationalStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/EFCore.Relational/Properties/RelationalStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -379,18 +379,18 @@
<data name="ErrorMaterializingValueNullReference" xml:space="preserve">
<value>An error occurred while reading a database value. The expected type was '{expectedType}' but the actual value was null.</value>
</data>
<data name="ExecuteDeleteOnNonEntityType" xml:space="preserve">
<value>The operation 'ExecuteDelete' requires an entity type which corresponds to the database table to be modified. The current operation is being applied on a non-entity projection. Remove any projection to non-entity types.</value>
</data>
<data name="ExecuteDeleteOnTableSplitting" xml:space="preserve">
<value>The operation '{operation}' is being applied on the table '{tableName}' which contains data for multiple entity types. Applying this delete operation will also delete data for other entity type(s), hence it is not supported.</value>
<value>The operation 'ExecuteDelete' is being applied on the table '{tableName}' which contains data for multiple entity types. Applying this delete operation will also delete data for other entity type(s), hence it is not supported.</value>
</data>
<data name="ExecuteOperationOnEntitySplitting" xml:space="preserve">
<value>The operation '{operation}' is being applied on entity type '{entityType}', which uses entity splitting. 'ExecuteDelete'/'ExecuteUpdate' operations on entity types using entity splitting is not supported.</value>
</data>
<data name="ExecuteOperationOnKeylessEntityTypeWithUnsupportedOperator" xml:space="preserve">
<value>The operation '{operation}' cannot be performed on keyless entity type '{entityType}', since it contains an operator not natively supported by the database provider.</value>
</data>
<data name="ExecuteOperationOnNonEntityType" xml:space="preserve">
<value>The operation '{operation}' requires an entity type which corresponds to the database table to be modified. The current operation is being applied on a non-entity projection. Remove any projection to non-entity types.</value>
</data>
<data name="ExecuteOperationOnTPC" xml:space="preserve">
<value>The operation '{operation}' is being applied on entity type '{entityType}', which is using the TPC mapping strategy and is not a leaf type. 'ExecuteDelete'/'ExecuteUpdate' operations on entity types participating in TPC hierarchies is only supported for leaf types.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp
{
if (source.ShaperExpression is not EntityShaperExpression entityShaperExpression)
{
AddTranslationErrorDetails(RelationalStrings.ExecuteOperationOnNonEntityType(nameof(RelationalQueryableExtensions.ExecuteDelete)));
AddTranslationErrorDetails(RelationalStrings.ExecuteDeleteOnNonEntityType);
return null;
}

Expand Down Expand Up @@ -1053,8 +1053,7 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp
&& tableExpression.Table.EntityTypeMappings.Any(e => e.EntityType.GetRootType() != entityType.GetRootType())))
{
AddTranslationErrorDetails(
RelationalStrings.ExecuteDeleteOnTableSplitting(
nameof(RelationalQueryableExtensions.ExecuteDelete), tableExpression.Table.SchemaQualifiedName));
RelationalStrings.ExecuteDeleteOnTableSplitting(tableExpression.Table.SchemaQualifiedName));

return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public virtual Task Delete_Except(bool async)
[MemberData(nameof(IsAsyncData))]
public virtual Task Delete_non_entity_projection(bool async)
=> AssertTranslationFailed(
RelationalStrings.ExecuteOperationOnNonEntityType("ExecuteDelete"),
RelationalStrings.ExecuteDeleteOnNonEntityType,
() => AssertDelete(
async,
ss => ss.Set<OrderDetail>().Where(od => od.OrderID < 10250).Select(e => e.ProductID),
Expand All @@ -247,7 +247,7 @@ public virtual Task Delete_non_entity_projection(bool async)
[MemberData(nameof(IsAsyncData))]
public virtual Task Delete_non_entity_projection_2(bool async)
=> AssertTranslationFailed(
RelationalStrings.ExecuteOperationOnNonEntityType("ExecuteDelete"),
RelationalStrings.ExecuteDeleteOnNonEntityType,
() => AssertDelete(
async,
ss => ss.Set<OrderDetail>().Where(od => od.OrderID < 10250)
Expand All @@ -258,7 +258,7 @@ public virtual Task Delete_non_entity_projection_2(bool async)
[MemberData(nameof(IsAsyncData))]
public virtual Task Delete_non_entity_projection_3(bool async)
=> AssertTranslationFailed(
RelationalStrings.ExecuteOperationOnNonEntityType("ExecuteDelete"),
RelationalStrings.ExecuteDeleteOnNonEntityType,
() => AssertDelete(
async,
ss => ss.Set<OrderDetail>().Where(od => od.OrderID < 10250)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ await TestHelpers.ExecuteWithStrategyInTransactionAsync(
UseTransaction,
async context => Assert.Contains(
RelationalStrings.NonQueryTranslationFailedWithDetails(
"", RelationalStrings.ExecuteDeleteOnTableSplitting("ExecuteDelete", "Vehicles"))[21..],
"", RelationalStrings.ExecuteDeleteOnTableSplitting("Vehicles"))[21..],
(await Assert.ThrowsAsync<InvalidOperationException>(() => context.Set<Vehicle>().ExecuteDeleteAsync())).Message));
}
else
Expand All @@ -641,7 +641,7 @@ await TestHelpers.ExecuteWithStrategyInTransactionAsync(
UseTransaction,
context => Assert.Contains(
RelationalStrings.NonQueryTranslationFailedWithDetails(
"", RelationalStrings.ExecuteDeleteOnTableSplitting("ExecuteDelete", "Vehicles"))[21..],
"", RelationalStrings.ExecuteDeleteOnTableSplitting("Vehicles"))[21..],
Assert.Throws<InvalidOperationException>(() => context.Set<Vehicle>().ExecuteDelete()).Message));
}
}
Expand Down

0 comments on commit 257ae5d

Please sign in to comment.