C# 将数据集与sql db表联接

C# 将数据集与sql db表联接,c#,sql,sql-server,c#-4.0,ado.net,C#,Sql,Sql Server,C# 4.0,Ado.net,我需要执行如下所示的查询,其中包含一个数据集 UPDATE <OrderDataset> SET FKProduct = P.PKProduct FROM <OrderDataset> DS INNER JOIN tblCustomer C ON DS.FKCustomer = C.PKCustomer INNER JOIN tblProduct P ON C.PKCustomer = P.FKCustomer INNER JOIN tblStock S ON

我需要执行如下所示的查询,其中包含一个数据集

UPDATE <OrderDataset> 
SET FKProduct = P.PKProduct 
FROM <OrderDataset> DS 
INNER JOIN tblCustomer C ON DS.FKCustomer = C.PKCustomer 
INNER JOIN tblProduct P ON C.PKCustomer = P.FKCustomer 
INNER JOIN tblStock S ON S.FKProduct = P.PKProduct 
AND DS.RotationNumber = S.RotationNumber 
AND ISNULL(DS.RotationLineNo,'NULL') = ISNULL(S.RotationLineNo,'NULL') 
WHERE DS.FKProduct IS NULL
更新
设置FKProduct=P.PKProduct
来自DS
DS.FKCustomer=C.PKCustomer上的内部联接tblCustomer C
C.PKCustomer=P.FKCustomer上的内部联接tblProduct P
S.FKProduct=P.PKProduct上的内部连接tblStock S
和DS.RotationNumber=S.RotationNumber
和ISNULL(DS.RotationLineNo,'NULL')=ISNULL(S.RotationLineNo,'NULL'))
其中DS.FKProduct为NULL

有没有办法实现这一点。

没有直接的方法

您可以将数据集中的表作为参数传递给sql server存储过程ans,然后在sp中执行jon


您可以使用Linq执行此操作