I was having an issue with the auto generated delete statement. In my mind the delete should have just been
DELETE [tablename] where [PK] = @param
but instead it generates a query with 4 ORs.
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)
The dataset tools almost insist on having queries involving PK/Indexes why does it generate such complex code?
Is this 'best practice' code, if it is can someone steer me to some documentation?
Surely the simple case is the 99% required code, the other 1% should be the times you need to edit the auto generated code or add our own.