寻找一个组合的insert/update/delete语句,merge正是我需要的,但我似乎找不到linq/sql是否支持它(从
http://www.sqlbook.com/SQL-Server/SQL-MERGE-35.aspx
)
-- Merge order items into OrderItems table
MERGE INTO OrderItem As oi
USING @UpdatedItems ui
ON (oi.OrderID = ui.OrderID AND oi.ProductID = ui.ProductID)
WHEN MATCHED THEN
UPDATE SET Quantity = ui.Quantity, UnitCost = ui.UnitCost
WHEN NOT MATCHED THEN
INSERT (OrderID, ProductID, Quantity, UnitCost)
VALUES (@OrderID, ui.ProductID, ui.Quantity, ui.UnitCost)
WHEN SOURCE NOT MATCHED THEN
DELETE;