EntityFramework.Utilities
EntityFramework.Utilities copied to clipboard
Update By Query: The variable name '@p__linq__0' has already been declared.
When ever I try to do a update by query, i get the following Exception message:
"The variable name '@p__linq__0' has already been declared. Variable names must be unique within a query batch or stored procedure."
Can you provide a code example that reproduces this issue?
Hi, I have similar problem, there is an example (like your example EFBatchOperation.For(db, db.Comments).Where(x => x.Text == "a").Update(x => x.Reads, x => x.Reads + 1);)
var value1 = 1 var value2 = 2 EFBatchOperation.For(db, db.Comments) .Where(x => x.Reads == value1) .Update(x => x.Reads, x => value2); The variable name '@p__linq__0' has already been declared... is thrown Note: If I have used constant instead of variables all is OK But I would like to execute update Comments set Reads = @2 where Reads = @1 Thanks Dusan
Another example:
var userId = 1;
var now = DateTime.UtcNow;
EFBatchOperation.For(db, db.Comments)
.Where(x => x.UserId == userId && x.ReadAt == null)
.Update(x => x.ReadAt, x => now);