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 nullable field #65

Open vadimMorozov opened 8 years ago

vadimMorozov commented 8 years ago

When updating a nullable field EFU generates wrong code.

Example: ================== Generated SQL ==================== UPDATE [dbo].[customer] SET [legalAddressId] = @plinq0 OR ([legalAddressId] IS NULL) WHERE ([legalAddressId] IN (cast('3c966889-4e55-44f3-b939-69e89f599e62' as uniqueidentifier))) AND ([legalAddressId] IS NOT NULL) ================== End Generated SQL ====================

================== Field Declaration ==================== [legalAddressId] UNIQEUIDENTIFIER NULL ================== End Field Declaration ====================

================== C# Source Code ==================== Guid? firstId; List<Guid?> idsToDelete; ... EFBatchOperation .For(dataEntity, dataEntity.customer) .Where(a => idsToDelete.Contains(a.legalAddressId)) .Update(a => a.legalAddressId, b => firstId); ================== End C# Source Code ====================