我正在更新一组对象,但是更新在一个SqlException上失败,该异常表示“Where附近的语法不正确”。
所以我打开SqlProfiler,下面是生成的SQL:
exec sp_executesql N'UPDATE [dbo].[Addresses]
SET
WHERE ([AddressID] = @p0) AND ([StreetAddress] = @p1) AND ([StreetAddress2] = @p2) AND ([City] = @p3) AND ([State] = @p4) AND ([ZipCode] = @p5) AND ([CoordinateID] = @p6) AND ([CoordinateSourceID] IS NULL) AND ([CreatedDate] = @p7) AND ([Country] = @p8) AND (NOT ([IsDeleted] = 1)) AND (NOT ([IsNonSACOGZip] = 1))',N'@p0 uniqueidentifier,@p1 varchar(15),@p2 varchar(8000),@p3 varchar(10),@p4 varchar(2),@p5 varchar(5),@p6 uniqueidentifier,@p7 datetime,@p8 varchar(2)',@p0='92550F32-D921-4B71-9622-6F1EC6123FB1',@p1='125 Main Street',@p2='',@p3='Sacramento',@p4='CA',@p5='95864',@p6='725E7939-AEE3-4EF9-A033-7507579B69DF',@p7='2010-06-15 14:07:51.0100000',@p8='US'
我还调用了context.GetChangeSet(),正确的值在updates部分。
另外,我检查了.dbml文件,所有的属性更新检查值都是“Always”。
我完全搞不懂这件事,有什么帮助吗?