0

我遇到了自动生成的删除语句的问题。在我看来,删除应该只是

DELETE [tablename] where [PK] = @param

但它会生成一个带有 4 个 OR 的查询。

DELETE FROM Market
WHERE     (@IsNull_Name = 1) 
AND (Name IS NULL) 
AND (@IsNull_Description = 1) 
AND (Description IS NULL) 
AND (MarketId = @Original_MarketId) 
OR
(@IsNull_Name = 1) 
AND (Name IS NULL) 
AND (Description = @Original_Description) 
AND (MarketId = @Original_MarketId) 
OR
(Name = @Original_Name) 
AND (@IsNull_Description = 1) 
AND (Description IS NULL) 
AND (MarketId = @Original_MarketId) 
OR
(Name = @Original_Name) 
AND (Description = @Original_Description) 
AND (MarketId = @Original_MarketId)

数据集工具几乎坚持查询涉及 PK/Indexes 为什么会生成如此复杂的代码?

这是“最佳实践”代码吗,如果有人可以引导我阅读一些文档吗?

当然,最简单的情况是需要 99% 的代码,另外 1% 应该是您需要编辑自动生成的代码或添加我们自己的代码的时间。

4

1 回答 1

1

这是基于乐观并发 - 它需要在删除之前检查所有值是否相同。

于 2009-04-03T10:13:22.910 回答