diff --git a/src/EFCore.Cosmos/Metadata/Conventions/CosmosRuntimeModelConvention.cs b/src/EFCore.Cosmos/Metadata/Conventions/CosmosRuntimeModelConvention.cs index fe05db49432..8509072cdeb 100644 --- a/src/EFCore.Cosmos/Metadata/Conventions/CosmosRuntimeModelConvention.cs +++ b/src/EFCore.Cosmos/Metadata/Conventions/CosmosRuntimeModelConvention.cs @@ -56,7 +56,7 @@ protected override void ProcessModelAnnotations( /// The target entity type that will contain the annotations. /// Indicates whether the given annotations are runtime annotations. protected override void ProcessEntityTypeAnnotations( - IDictionary annotations, + Dictionary annotations, IEntityType entityType, RuntimeEntityType runtimeEntityType, bool runtime) diff --git a/src/EFCore.Relational/Extensions/RelationalQueryableExtensions.cs b/src/EFCore.Relational/Extensions/RelationalQueryableExtensions.cs index 3fd587bfcc7..85715b76f2c 100644 --- a/src/EFCore.Relational/Extensions/RelationalQueryableExtensions.cs +++ b/src/EFCore.Relational/Extensions/RelationalQueryableExtensions.cs @@ -342,13 +342,13 @@ internal static readonly MethodInfo ExecuteDeleteMethodInfo /// /// /// The source query. - /// A collection of set property statements specifying properties to update. + /// A collection of set property statements specifying properties to update. /// The total number of rows updated in the database. public static int ExecuteUpdate( this IQueryable source, - Expression, SetPropertyStatements>> setPropertyStatements) + Expression, SetPropertyCalls>> setPropertyCalls) => source.Provider.Execute( - Expression.Call(ExecuteUpdateMethodInfo.MakeGenericMethod(typeof(TSource)), source.Expression, setPropertyStatements)); + Expression.Call(ExecuteUpdateMethodInfo.MakeGenericMethod(typeof(TSource)), source.Expression, setPropertyCalls)); /// /// Asynchronously updates database rows for the entity instances which match the LINQ query from the database. @@ -366,17 +366,17 @@ public static int ExecuteUpdate( /// /// /// The source query. - /// A collection of set property statements specifying properties to update. + /// A collection of set property statements specifying properties to update. /// A to observe while waiting for the task to complete. /// The total number of rows updated in the database. public static Task ExecuteUpdateAsync( this IQueryable source, - Expression, SetPropertyStatements>> setPropertyStatements, + Expression, SetPropertyCalls>> setPropertyCalls, CancellationToken cancellationToken = default) => source.Provider is IAsyncQueryProvider provider ? provider.ExecuteAsync>( Expression.Call( - ExecuteUpdateMethodInfo.MakeGenericMethod(typeof(TSource)), source.Expression, setPropertyStatements), cancellationToken) + ExecuteUpdateMethodInfo.MakeGenericMethod(typeof(TSource)), source.Expression, setPropertyCalls), cancellationToken) : throw new InvalidOperationException(CoreStrings.IQueryableProviderNotAsync); internal static readonly MethodInfo ExecuteUpdateMethodInfo diff --git a/src/EFCore.Relational/Metadata/Conventions/RelationalRuntimeModelConvention.cs b/src/EFCore.Relational/Metadata/Conventions/RelationalRuntimeModelConvention.cs index 5fa76e3a913..85cffeec6fd 100644 --- a/src/EFCore.Relational/Metadata/Conventions/RelationalRuntimeModelConvention.cs +++ b/src/EFCore.Relational/Metadata/Conventions/RelationalRuntimeModelConvention.cs @@ -113,7 +113,7 @@ protected override void ProcessModelAnnotations( /// The target entity type that will contain the annotations. /// Indicates whether the given annotations are runtime annotations. protected override void ProcessEntityTypeAnnotations( - IDictionary annotations, + Dictionary annotations, IEntityType entityType, RuntimeEntityType runtimeEntityType, bool runtime) @@ -405,7 +405,7 @@ protected virtual void ProcessPropertyOverridesAnnotations( /// The target key that will contain the annotations. /// Indicates whether the given annotations are runtime annotations. protected override void ProcessKeyAnnotations( - IDictionary annotations, + Dictionary annotations, IKey key, RuntimeKey runtimeKey, bool runtime) diff --git a/src/EFCore.Relational/Properties/RelationalStrings.Designer.cs b/src/EFCore.Relational/Properties/RelationalStrings.Designer.cs index 86b0ea4614f..5a656f0a0e7 100644 --- a/src/EFCore.Relational/Properties/RelationalStrings.Designer.cs +++ b/src/EFCore.Relational/Properties/RelationalStrings.Designer.cs @@ -872,7 +872,7 @@ public static string InsufficientInformationToIdentifyElementOfCollectionJoin => GetString("InsufficientInformationToIdentifyElementOfCollectionJoin"); /// - /// The 'setPropertyStatements' argument to 'ExecuteUpdate' may only contain a chain of 'SetProperty' expressing the properties to be updated. + /// The 'setPropertyCalls' argument to 'ExecuteUpdate' may only contain a chain of 'SetProperty' expressing the properties to be updated. /// public static string InvalidArgumentToExecuteUpdate => GetString("InvalidArgumentToExecuteUpdate"); diff --git a/src/EFCore.Relational/Properties/RelationalStrings.resx b/src/EFCore.Relational/Properties/RelationalStrings.resx index 3eb627796b8..c0f260808be 100644 --- a/src/EFCore.Relational/Properties/RelationalStrings.resx +++ b/src/EFCore.Relational/Properties/RelationalStrings.resx @@ -443,7 +443,7 @@ Unable to translate a collection subquery in a projection since either parent or the subquery doesn't project necessary information required to uniquely identify it and correctly generate results on the client side. This can happen when trying to correlate on keyless entity type. This can also happen for some cases of projection before 'Distinct' or some shapes of grouping key in case of 'GroupBy'. These should either contain all key properties of the entity that the operation is applied on, or only contain simple property access expressions. - The 'setPropertyStatements' argument to 'ExecuteUpdate' may only contain a chain of 'SetProperty' expressing the properties to be updated. + The 'setPropertyCalls' argument to 'ExecuteUpdate' may only contain a chain of 'SetProperty' expressing the properties to be updated. The specified 'CommandTimeout' value '{value}' is not valid. It must be a positive number. diff --git a/src/EFCore.Relational/Query/Internal/SelectExpressionPruningExpressionVisitor.cs b/src/EFCore.Relational/Query/Internal/SelectExpressionPruningExpressionVisitor.cs index 2d40657fd4b..ab7788ea5b4 100644 --- a/src/EFCore.Relational/Query/Internal/SelectExpressionPruningExpressionVisitor.cs +++ b/src/EFCore.Relational/Query/Internal/SelectExpressionPruningExpressionVisitor.cs @@ -43,7 +43,7 @@ public class SelectExpressionPruningExpressionVisitor : ExpressionVisitor case UpdateExpression updateExpression: return updateExpression.Update( updateExpression.SelectExpression.Prune(), - updateExpression.SetColumnValues.Select(e => new SetColumnValue(e.Column, (SqlExpression)Visit(e.Value))).ToList()); + updateExpression.ColumnValueSetters.Select(e => new ColumnValueSetter(e.Column, (SqlExpression)Visit(e.Value))).ToList()); default: return base.Visit(expression); diff --git a/src/EFCore.Relational/Query/QuerySqlGenerator.cs b/src/EFCore.Relational/Query/QuerySqlGenerator.cs index f32420c4660..49b9cc86077 100644 --- a/src/EFCore.Relational/Query/QuerySqlGenerator.cs +++ b/src/EFCore.Relational/Query/QuerySqlGenerator.cs @@ -1246,7 +1246,7 @@ protected override Expression VisitUpdate(UpdateExpression updateExpression) using (_relationalCommandBuilder.Indent()) { _relationalCommandBuilder.Append("SET "); - GenerateList(updateExpression.SetColumnValues, + GenerateList(updateExpression.ColumnValueSetters, e => { _relationalCommandBuilder.Append($"{_sqlGenerationHelper.DelimitIdentifier(e.Column.Name)} = "); diff --git a/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs index 99afa6f307e..7575d8a5085 100644 --- a/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs +++ b/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs @@ -1104,18 +1104,18 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp } /// - /// Translates method + /// Translates method /// over the given source. /// /// The shaped query on which the operator is applied. - /// The lambda expression containing statements. + /// The lambda expression containing statements. /// The non query after translation. protected virtual NonQueryExpression? TranslateExecuteUpdate( ShapedQueryExpression source, - LambdaExpression setPropertyStatements) + LambdaExpression setPropertyCalls) { var propertyValueLambdaExpressions = new List<(LambdaExpression, LambdaExpression)>(); - PopulateSetPropertyStatements(setPropertyStatements.Body, propertyValueLambdaExpressions, setPropertyStatements.Parameters[0]); + PopulateSetPropertyCalls(setPropertyCalls.Body, propertyValueLambdaExpressions, setPropertyCalls.Parameters[0]); if (TranslationErrorDetails != null) { return null; @@ -1248,7 +1248,7 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp List<(LambdaExpression, LambdaExpression)> propertyValueLambdaExpressions, List? leftExpressions) { - var setColumnValues = new List(); + var columnValueSetters = new List(); for (var i = 0; i < propertyValueLambdaExpressions.Count; i++) { var (propertyExpression, valueExpression) = propertyValueLambdaExpressions[i]; @@ -1274,7 +1274,7 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp var translation = visitor._sqlTranslator.Translate(setter); if (translation is SqlBinaryExpression { OperatorType: ExpressionType.Equal, Left: ColumnExpression column } sqlBinaryExpression) { - setColumnValues.Add(new SetColumnValue(column, sqlBinaryExpression.Right)); + columnValueSetters.Add(new ColumnValueSetter(column, sqlBinaryExpression.Right)); } else { @@ -1288,10 +1288,10 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp selectExpression.ReplaceProjection(new List()); selectExpression.ApplyProjection(); - return new NonQueryExpression(new UpdateExpression(tableExpression, selectExpression, setColumnValues)); + return new NonQueryExpression(new UpdateExpression(tableExpression, selectExpression, columnValueSetters)); } - void PopulateSetPropertyStatements( + void PopulateSetPropertyCalls( Expression expression, List<(LambdaExpression, LambdaExpression)> list, ParameterExpression parameter) { switch (expression) @@ -1302,13 +1302,13 @@ void PopulateSetPropertyStatements( case MethodCallExpression methodCallExpression when methodCallExpression.Method.IsGenericMethod - && methodCallExpression.Method.Name == nameof(SetPropertyStatements.SetProperty) + && methodCallExpression.Method.Name == nameof(SetPropertyCalls.SetProperty) && methodCallExpression.Method.DeclaringType!.IsGenericType - && methodCallExpression.Method.DeclaringType.GetGenericTypeDefinition() == typeof(SetPropertyStatements<>): + && methodCallExpression.Method.DeclaringType.GetGenericTypeDefinition() == typeof(SetPropertyCalls<>): list.Add((methodCallExpression.Arguments[0].UnwrapLambdaFromQuote(), methodCallExpression.Arguments[1].UnwrapLambdaFromQuote())); - PopulateSetPropertyStatements(methodCallExpression.Object!, list, parameter); + PopulateSetPropertyCalls(methodCallExpression.Object!, list, parameter); break; diff --git a/src/EFCore.Relational/Query/SetPropertyStatements.cs b/src/EFCore.Relational/Query/SetPropertyCalls.cs similarity index 56% rename from src/EFCore.Relational/Query/SetPropertyStatements.cs rename to src/EFCore.Relational/Query/SetPropertyCalls.cs index 3972a42d536..26489033a60 100644 --- a/src/EFCore.Relational/Query/SetPropertyStatements.cs +++ b/src/EFCore.Relational/Query/SetPropertyCalls.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel; + namespace Microsoft.EntityFrameworkCore.Query; /// @@ -18,8 +20,12 @@ namespace Microsoft.EntityFrameworkCore.Query; /// and How EF Core queries work for more information and examples. /// /// The type of source element on which ExecuteUpdate operation is being applied. -public sealed class SetPropertyStatements +public sealed class SetPropertyCalls { + private SetPropertyCalls() + { + } + /// /// Specifies a property and corresponding value it should be updated to in ExecuteUpdate method. /// @@ -27,10 +33,41 @@ public sealed class SetPropertyStatements /// A property access expression. /// A value expression. /// The same instance so that multiple calls to can be chained. - public SetPropertyStatements SetProperty( + public SetPropertyCalls SetProperty( Expression> propertyExpression, Expression> valueExpression) { throw new InvalidOperationException(RelationalStrings.SetPropertyMethodInvoked); } + + #region Hidden System.Object members + + /// + /// Returns a string that represents the current object. + /// + /// A string that represents the current object. + [EditorBrowsable(EditorBrowsableState.Never)] + public override string? ToString() + => base.ToString(); + + /// + /// Determines whether the specified object is equal to the current object. + /// + /// The object to compare with the current object. + /// if the specified object is equal to the current object; otherwise, . + [EditorBrowsable(EditorBrowsableState.Never)] + // ReSharper disable once BaseObjectEqualsIsObjectEquals + public override bool Equals(object? obj) + => base.Equals(obj); + + /// + /// Serves as the default hash function. + /// + /// A hash code for the current object. + [EditorBrowsable(EditorBrowsableState.Never)] + // ReSharper disable once BaseObjectGetHashCodeCallInGetHashCode + public override int GetHashCode() + => base.GetHashCode(); + + #endregion } diff --git a/src/EFCore.Relational/Query/SqlExpressions/SetColumnValue.cs b/src/EFCore.Relational/Query/SqlExpressions/ColumnValueSetter.cs similarity index 74% rename from src/EFCore.Relational/Query/SqlExpressions/SetColumnValue.cs rename to src/EFCore.Relational/Query/SqlExpressions/ColumnValueSetter.cs index 72bae3169ab..99debf2f445 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/SetColumnValue.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/ColumnValueSetter.cs @@ -12,14 +12,14 @@ namespace Microsoft.EntityFrameworkCore.Query.SqlExpressions; /// not used in application code. /// /// -public class SetColumnValue +public class ColumnValueSetter { /// - /// Creates a new instance of the class. + /// Creates a new instance of the class. /// /// A column to be updated. /// A value to be assigned to the column. - public SetColumnValue(ColumnExpression column, SqlExpression value) + public ColumnValueSetter(ColumnExpression column, SqlExpression value) { Column = column; Value = value; @@ -39,12 +39,12 @@ public SetColumnValue(ColumnExpression column, SqlExpression value) public override bool Equals(object? obj) => obj != null && (ReferenceEquals(this, obj) - || obj is SetColumnValue setColumnValue - && Equals(setColumnValue)); + || obj is ColumnValueSetter columnValueSetter + && Equals(columnValueSetter)); - private bool Equals(SetColumnValue setColumnValue) - => Column == setColumnValue.Column - && Value == setColumnValue.Value; + private bool Equals(ColumnValueSetter columnValueSetter) + => Column == columnValueSetter.Column + && Value == columnValueSetter.Value; /// public override int GetHashCode() => HashCode.Combine(Column, Value); diff --git a/src/EFCore.Relational/Query/SqlExpressions/UpdateExpression.cs b/src/EFCore.Relational/Query/SqlExpressions/UpdateExpression.cs index 7a41ae30dca..7d7f9b796e7 100644 --- a/src/EFCore.Relational/Query/SqlExpressions/UpdateExpression.cs +++ b/src/EFCore.Relational/Query/SqlExpressions/UpdateExpression.cs @@ -19,12 +19,12 @@ public sealed class UpdateExpression : Expression, IPrintableExpression /// /// A table on which the update operation is being applied. /// A select expression which is used to determine which rows to update and to get data from additional tables. - /// A list of which specifies columns and their corresponding values to update. - public UpdateExpression(TableExpression table, SelectExpression selectExpression, IReadOnlyList setColumnValues) + /// A list of which specifies columns and their corresponding values to update. + public UpdateExpression(TableExpression table, SelectExpression selectExpression, IReadOnlyList columnValueSetters) { Table = table; SelectExpression = selectExpression; - SetColumnValues = setColumnValues; + ColumnValueSetters = columnValueSetters; } /// @@ -38,9 +38,9 @@ public UpdateExpression(TableExpression table, SelectExpression selectExpression public SelectExpression SelectExpression { get; } /// - /// The list of which specifies columns and their corresponding values to update. + /// The list of which specifies columns and their corresponding values to update. /// - public IReadOnlyList SetColumnValues { get; } + public IReadOnlyList ColumnValueSetters { get; } /// public override Type Type @@ -54,29 +54,29 @@ public sealed override ExpressionType NodeType protected override Expression VisitChildren(ExpressionVisitor visitor) { var selectExpression = (SelectExpression)visitor.Visit(SelectExpression); - List? setColumnValues = null; - for (var (i, n) = (0, SetColumnValues.Count); i < n; i++) + List? columnValueSetters = null; + for (var (i, n) = (0, ColumnValueSetters.Count); i < n; i++) { - var setColumnValue = SetColumnValues[i]; - var newValue = (SqlExpression)visitor.Visit(setColumnValue.Value); - if (setColumnValues != null) + var columnValueSetter = ColumnValueSetters[i]; + var newValue = (SqlExpression)visitor.Visit(columnValueSetter.Value); + if (columnValueSetters != null) { - setColumnValues.Add(new SetColumnValue(setColumnValue.Column, newValue)); + columnValueSetters.Add(new ColumnValueSetter(columnValueSetter.Column, newValue)); } - else if (!ReferenceEquals(newValue, setColumnValue.Value)) + else if (!ReferenceEquals(newValue, columnValueSetter.Value)) { - setColumnValues = new(n); + columnValueSetters = new(n); for (var j = 0; j < i; j++) { - setColumnValues.Add(SetColumnValues[j]); + columnValueSetters.Add(ColumnValueSetters[j]); } - setColumnValues.Add(new SetColumnValue(setColumnValue.Column, newValue)); + columnValueSetters.Add(new ColumnValueSetter(columnValueSetter.Column, newValue)); } } return selectExpression != SelectExpression - || setColumnValues != null - ? new UpdateExpression(Table, selectExpression, setColumnValues ?? SetColumnValues) + || columnValueSetters != null + ? new UpdateExpression(Table, selectExpression, columnValueSetters ?? ColumnValueSetters) : this; } @@ -85,11 +85,11 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// return this expression. /// /// The property of the result. - /// The property of the result. + /// The property of the result. /// This expression if no children changed, or an expression with the updated children. - public UpdateExpression Update(SelectExpression selectExpression, IReadOnlyList setColumnValues) - => selectExpression != SelectExpression || !SetColumnValues.SequenceEqual(setColumnValues) - ? new UpdateExpression(Table, selectExpression, setColumnValues) + public UpdateExpression Update(SelectExpression selectExpression, IReadOnlyList columnValueSetters) + => selectExpression != SelectExpression || !ColumnValueSetters.SequenceEqual(columnValueSetters) + ? new UpdateExpression(Table, selectExpression, columnValueSetters) : this; /// @@ -100,7 +100,7 @@ public void Print(ExpressionPrinter expressionPrinter) using (expressionPrinter.Indent()) { var first = true; - foreach (var setColumnValue in SetColumnValues) + foreach (var columnValueSetter in ColumnValueSetters) { if (first) { @@ -110,9 +110,9 @@ public void Print(ExpressionPrinter expressionPrinter) { expressionPrinter.AppendLine(","); } - expressionPrinter.Visit(setColumnValue.Column); + expressionPrinter.Visit(columnValueSetter.Column); expressionPrinter.Append(" = "); - expressionPrinter.Visit(setColumnValue.Value); + expressionPrinter.Visit(columnValueSetter.Value); } } expressionPrinter.Visit(SelectExpression); @@ -128,7 +128,7 @@ public override bool Equals(object? obj) private bool Equals(UpdateExpression updateExpression) => Table == updateExpression.Table && SelectExpression == updateExpression.SelectExpression - && SetColumnValues.SequenceEqual(updateExpression.SetColumnValues); + && ColumnValueSetters.SequenceEqual(updateExpression.ColumnValueSetters); /// public override int GetHashCode() @@ -136,7 +136,7 @@ public override int GetHashCode() var hash = new HashCode(); hash.Add(Table); hash.Add(SelectExpression); - foreach (var item in SetColumnValues) + foreach (var item in ColumnValueSetters) { hash.Add(item); } diff --git a/src/EFCore.Relational/Query/SqlNullabilityProcessor.cs b/src/EFCore.Relational/Query/SqlNullabilityProcessor.cs index 1eaf3487b90..7fd0f6156db 100644 --- a/src/EFCore.Relational/Query/SqlNullabilityProcessor.cs +++ b/src/EFCore.Relational/Query/SqlNullabilityProcessor.cs @@ -90,29 +90,29 @@ public virtual Expression Process( private UpdateExpression VisitUpdate(UpdateExpression updateExpression) { var selectExpression = Visit(updateExpression.SelectExpression); - List? setColumnValues = null; - for (var (i, n) = (0, updateExpression.SetColumnValues.Count); i < n; i++) + List? columnValueSetters = null; + for (var (i, n) = (0, updateExpression.ColumnValueSetters.Count); i < n; i++) { - var setColumnValue = updateExpression.SetColumnValues[i]; - var newValue = Visit(setColumnValue.Value, out _); - if (setColumnValues != null) + var columnValueSetter = updateExpression.ColumnValueSetters[i]; + var newValue = Visit(columnValueSetter.Value, out _); + if (columnValueSetters != null) { - setColumnValues.Add(new SetColumnValue(setColumnValue.Column, newValue)); + columnValueSetters.Add(new ColumnValueSetter(columnValueSetter.Column, newValue)); } - else if (!ReferenceEquals(newValue, setColumnValue.Value)) + else if (!ReferenceEquals(newValue, columnValueSetter.Value)) { - setColumnValues = new(n); + columnValueSetters = new(n); for (var j = 0; j < i; j++) { - setColumnValues.Add(updateExpression.SetColumnValues[j]); + columnValueSetters.Add(updateExpression.ColumnValueSetters[j]); } - setColumnValues.Add(new SetColumnValue(setColumnValue.Column, newValue)); + columnValueSetters.Add(new ColumnValueSetter(columnValueSetter.Column, newValue)); } } return selectExpression != updateExpression.SelectExpression - || setColumnValues != null - ? new UpdateExpression(updateExpression.Table, selectExpression, setColumnValues ?? updateExpression.SetColumnValues) + || columnValueSetters != null + ? updateExpression.Update(selectExpression, columnValueSetters ?? updateExpression.ColumnValueSetters) : updateExpression; } diff --git a/src/EFCore.SqlServer/Metadata/Conventions/SqlServerRuntimeModelConvention.cs b/src/EFCore.SqlServer/Metadata/Conventions/SqlServerRuntimeModelConvention.cs index 76fb8b3bc92..b80a814f8bd 100644 --- a/src/EFCore.SqlServer/Metadata/Conventions/SqlServerRuntimeModelConvention.cs +++ b/src/EFCore.SqlServer/Metadata/Conventions/SqlServerRuntimeModelConvention.cs @@ -106,7 +106,7 @@ protected override void ProcessIndexAnnotations( /// protected override void ProcessKeyAnnotations( - IDictionary annotations, + Dictionary annotations, IKey key, RuntimeKey runtimeKey, bool runtime) @@ -121,7 +121,7 @@ protected override void ProcessKeyAnnotations( /// protected override void ProcessEntityTypeAnnotations( - IDictionary annotations, + Dictionary annotations, IEntityType entityType, RuntimeEntityType runtimeEntityType, bool runtime) diff --git a/src/EFCore.SqlServer/Query/Internal/SearchConditionConvertingExpressionVisitor.cs b/src/EFCore.SqlServer/Query/Internal/SearchConditionConvertingExpressionVisitor.cs index 9cdb7842578..d86e8e07ea5 100644 --- a/src/EFCore.SqlServer/Query/Internal/SearchConditionConvertingExpressionVisitor.cs +++ b/src/EFCore.SqlServer/Query/Internal/SearchConditionConvertingExpressionVisitor.cs @@ -732,27 +732,27 @@ protected override Expression VisitUpdate(UpdateExpression updateExpression) var selectExpression = (SelectExpression)Visit(updateExpression.SelectExpression); var parentSearchCondition = _isSearchCondition; _isSearchCondition = false; - List? setColumnValues = null; - for (var (i, n) = (0, updateExpression.SetColumnValues.Count); i < n; i++) + List? columnValueSetters = null; + for (var (i, n) = (0, updateExpression.ColumnValueSetters.Count); i < n; i++) { - var setColumnValue = updateExpression.SetColumnValues[i]; - var newValue = (SqlExpression)Visit(setColumnValue.Value); - if (setColumnValues != null) + var columnValueSetter = updateExpression.ColumnValueSetters[i]; + var newValue = (SqlExpression)Visit(columnValueSetter.Value); + if (columnValueSetters != null) { - setColumnValues.Add(new SetColumnValue(setColumnValue.Column, newValue)); + columnValueSetters.Add(new ColumnValueSetter(columnValueSetter.Column, newValue)); } - else if (!ReferenceEquals(newValue, setColumnValue.Value)) + else if (!ReferenceEquals(newValue, columnValueSetter.Value)) { - setColumnValues = new(); + columnValueSetters = new(); for (var j = 0; j < i; j++) { - setColumnValues.Add(updateExpression.SetColumnValues[j]); + columnValueSetters.Add(updateExpression.ColumnValueSetters[j]); } - setColumnValues.Add(new SetColumnValue(setColumnValue.Column, newValue)); + columnValueSetters.Add(new ColumnValueSetter(columnValueSetter.Column, newValue)); } } _isSearchCondition = parentSearchCondition; - return updateExpression.Update(selectExpression, setColumnValues ?? updateExpression.SetColumnValues); + return updateExpression.Update(selectExpression, columnValueSetters ?? updateExpression.ColumnValueSetters); } /// diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs index 03ef76e406e..073b6679c09 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs @@ -94,7 +94,7 @@ protected override Expression VisitUpdate(UpdateExpression updateExpression) using (Sql.Indent()) { Sql.Append("SET "); - GenerateList(updateExpression.SetColumnValues, + GenerateList(updateExpression.ColumnValueSetters, e => { Visit(e.Column); diff --git a/src/EFCore/Metadata/Conventions/RuntimeModelConvention.cs b/src/EFCore/Metadata/Conventions/RuntimeModelConvention.cs index e8cc5b2c045..b127ecc9905 100644 --- a/src/EFCore/Metadata/Conventions/RuntimeModelConvention.cs +++ b/src/EFCore/Metadata/Conventions/RuntimeModelConvention.cs @@ -257,7 +257,7 @@ private static ParameterBinding Create(ParameterBinding parameterBinding, Runtim /// The target entity type that will contain the annotations. /// Indicates whether the given annotations are runtime annotations. protected virtual void ProcessEntityTypeAnnotations( - IDictionary annotations, + Dictionary annotations, IEntityType entityType, RuntimeEntityType runtimeEntityType, bool runtime) @@ -427,7 +427,7 @@ private static RuntimeKey Create(IKey key, RuntimeEntityType runtimeEntityType) /// The target key that will contain the annotations. /// Indicates whether the given annotations are runtime annotations. protected virtual void ProcessKeyAnnotations( - IDictionary annotations, + Dictionary annotations, IKey key, RuntimeKey runtimeKey, bool runtime) diff --git a/test/EFCore.Relational.Specification.Tests/BulkUpdates/BulkUpdatesTestBase.cs b/test/EFCore.Relational.Specification.Tests/BulkUpdates/BulkUpdatesTestBase.cs index 963c21ae6f5..86e2343f0d7 100644 --- a/test/EFCore.Relational.Specification.Tests/BulkUpdates/BulkUpdatesTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/BulkUpdates/BulkUpdatesTestBase.cs @@ -31,11 +31,11 @@ public Task AssertUpdate( bool async, Func> query, Expression> entitySelector, - Expression, SetPropertyStatements>> setPropertyStatements, + Expression, SetPropertyCalls>> setPropertyCalls, int rowsAffectedCount, Action, IReadOnlyList> asserter = null) where TResult : class - => BulkUpdatesAsserter.AssertUpdate(async, query, entitySelector, setPropertyStatements, rowsAffectedCount, asserter); + => BulkUpdatesAsserter.AssertUpdate(async, query, entitySelector, setPropertyCalls, rowsAffectedCount, asserter); protected static async Task AssertTranslationFailed(string details, Func query) => Assert.Contains( diff --git a/test/EFCore.Relational.Specification.Tests/BulkUpdates/NonSharedModelBulkUpdatesTestBase.cs b/test/EFCore.Relational.Specification.Tests/BulkUpdates/NonSharedModelBulkUpdatesTestBase.cs index 96259bc98c3..cac3879fcfc 100644 --- a/test/EFCore.Relational.Specification.Tests/BulkUpdates/NonSharedModelBulkUpdatesTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/BulkUpdates/NonSharedModelBulkUpdatesTestBase.cs @@ -98,7 +98,7 @@ public async Task AssertUpdate( bool async, Func contextCreator, Func> query, - Expression, SetPropertyStatements>> setPropertyStatements, + Expression, SetPropertyCalls>> setPropertyCalls, int rowsAffectedCount) where TResult : class where TContext : DbContext @@ -111,7 +111,7 @@ await TestHelpers.ExecuteWithStrategyInTransactionAsync( { var processedQuery = query(context); - var result = await processedQuery.ExecuteUpdateAsync(setPropertyStatements); + var result = await processedQuery.ExecuteUpdateAsync(setPropertyCalls); Assert.Equal(rowsAffectedCount, result); }); @@ -124,7 +124,7 @@ await TestHelpers.ExecuteWithStrategyInTransactionAsync( { var processedQuery = query(context); - var result = processedQuery.ExecuteUpdate(setPropertyStatements); + var result = processedQuery.ExecuteUpdate(setPropertyCalls); Assert.Equal(rowsAffectedCount, result); }); diff --git a/test/EFCore.Relational.Specification.Tests/TestUtilities/BulkUpdatesAsserter.cs b/test/EFCore.Relational.Specification.Tests/TestUtilities/BulkUpdatesAsserter.cs index 5331d024055..4d37c8f6cbd 100644 --- a/test/EFCore.Relational.Specification.Tests/TestUtilities/BulkUpdatesAsserter.cs +++ b/test/EFCore.Relational.Specification.Tests/TestUtilities/BulkUpdatesAsserter.cs @@ -59,7 +59,7 @@ public async Task AssertUpdate( bool async, Func> query, Expression> entitySelector, - Expression, SetPropertyStatements>> setPropertyStatements, + Expression, SetPropertyCalls>> setPropertyCalls, int rowsAffectedCount, Action, IReadOnlyList> asserter) where TResult : class @@ -76,7 +76,7 @@ await TestHelpers.ExecuteWithStrategyInTransactionAsync( var before = processedQuery.AsNoTracking().Select(entitySelector).OrderBy(elementSorter).ToList(); - var result = await processedQuery.ExecuteUpdateAsync(setPropertyStatements); + var result = await processedQuery.ExecuteUpdateAsync(setPropertyCalls); Assert.Equal(rowsAffectedCount, result); @@ -95,7 +95,7 @@ await TestHelpers.ExecuteWithStrategyInTransactionAsync( var before = processedQuery.AsNoTracking().Select(entitySelector).OrderBy(elementSorter).ToList(); - var result = processedQuery.ExecuteUpdate(setPropertyStatements); + var result = processedQuery.ExecuteUpdate(setPropertyCalls); Assert.Equal(rowsAffectedCount, result);