Skip to content

Commit e1c1613

Browse files
committed
Fix Bulk set operation for entities
1 parent f2552f4 commit e1c1613

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

Extensions/Xtensive.Orm.BulkOperations/BulkExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public static IUpdatable<T> Set<T, TResult>(this IQueryable<T> query, Expression
8181
TResult value) where T: IEntity =>
8282
Set(query,
8383
field,
84-
Expression.Lambda<Func<T, TResult>>(Expression.Constant(value), Expression.Parameter(typeof(T), "a")) // Manually constructed expression is simpler than `a => value`
84+
Expression.Lambda<Func<T, TResult>>(Expression.Constant(value, typeof(TResult)), Expression.Parameter(typeof(T), "a")) // Manually constructed expression is simpler than `a => value`
8585
);
8686

8787
/// <summary>

Extensions/Xtensive.Orm.BulkOperations/Internals/SetOperation.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,10 @@ private void AddEntityValue(AddValueContext addContext)
227227
}
228228
}
229229
i = -1;
230-
var entity = (IEntity) FastExpression.Lambda(addContext.Lambda.Body).Compile().DynamicInvoke();
230+
var entity = (IEntity) (addContext.Lambda.Body is ConstantExpression ce
231+
? ce.Value
232+
: FastExpression.Lambda(addContext.Lambda.Body).Compile().DynamicInvoke());
233+
231234
foreach (ColumnInfo column in addContext.Field.Columns) {
232235
i++;
233236
SqlExpression value;

0 commit comments

Comments
 (0)