如何在 LINQ to Objects 中进行更新。尝试将 SQL 转换为 Linq
Quality
(
TransactionID int,
Quantity float,
MaterialID int,
ProductID int,
ParameterID int,
ParameterValue float,
TotalTonnes float
)
如何将以下 SQL 转换为 linq:
UPDATE Q1
SET TotalTonnes = ( SELECT SUM(Quantity)
FROM @Quality Q2
WHERE Q1.ParameterID = Q2.ParameterID
AND ( ( Q1.MaterialID = Q2.MaterialID )
OR ( Q1.MaterialID IS NULL
AND Q2.MaterialID IS NULL
)
)
AND ( ( Q1.ProductID = Q2.ProductID )
OR ( Q1.ProductID IS NULL
AND Q2.ProductID IS NULL
)
)
)
FROM @Quality Q1
谢谢