MikaelEliasson / EntityFramework.Utilities

Provides extensions for EntityFramework that doesn't exist out of the box like delete and update by query and bulk inserts
443 stars 175 forks source link

Updating with Where extension method #104

Open catinodeh opened 7 years ago

catinodeh commented 7 years ago

This code...

EFBatchOperation.For(_repo, _repo.CityServices) .Where(cs => cs.serviceid == serviceid && citiesInThisFieldOffice.Contains(cs.cityid) && cs.status) .Update(x => x.updatedby, x => userId);

..generated this update...

exec sp_executesql N'UPDATE [dbo].[cityservices] SET [updatedby] = @plinq0 WHERE ([serviceid] = @plinq0) AND ([cityid] IN (6688, 4934, 2215, 2302, 2210, 6725, 6749, 7217, 7241, 7329, 3959, 5615, 7405, 7406, 7412, 7414, 7417, 7425, 7432, 7443, 7444, 7448, 7449, 7450, 7452, 7456, 7463, 7464, 7465, 7471, 7473, 7476, 6946, 7389, 7142, 4519, 2231, 16756, 6763, 7256, 6719, 6371)) AND ([status] = 1)',N'@plinq0 int,@plinq0 int',@plinq0=531,@plinq0=711 go

System.Data.SqlClient.SqlException (0x80131904): The variable name '@plinq0' has already been declared. Variable names must be unique within a query batch or stored procedure.

The problem is that EFUtilities declared the same variable twice.

I'm using the latest release (1.0.2.0).

ShurikEv commented 1 year ago

How you fix it?