Can anyone help me with a LINQ query. I have converted most of it but i have a sub query in the stored procedure and i can t figure out how to do it..
这基本上是旧的储存程序(为了方便而实施的)。
SELECT M.Period AS Period ,
C.Code AS Group ,
C.ClientCode AS Code ,
C.ClientName AS Name ,
( SELECT SUM(Amount) AS Expr1
FROM M
WHERE ( ClientCode = C.ClientCode )
GROUP BY ClientCode
) AS Amount ,
从以上可以看出,问题就是如此。
SELECT SUM(Amount) AS Expr1
FROM M
WHERE ( ClientCode = C.ClientCode )
GROUP BY ClientCode
) AS Amount
因此,我已经与我一道工作,而且我迄今也这样做。
var test = from c in C join h in H on c.Code
equals h.Code join m in M on c.ClientCode
equals m.ClientCode
select new
{
Period=m.Period,
Group=c.Code,
Code= c.ClientCode,
Name= c.ClientName,
<-- Here is where i need the sub select query above -->
};
但是,就失去了如何做分局。 该栏的名称是你能够在旧储存程序中看到的数量。
我感谢任何反馈或帮助
THanks