3
我想创建一个LINQ查询,该查询返回父帐户及其所有子帐户的给定productnumber的所有数量的总和。是否可以在LINQ中创建相关的子查询?
我的产品表通过帐号,其中每行还包含一个数量和父账号:
PartNumber AccountNumber ParentAccountNumber Qty
---------- ------------- ------------------- ---
1000000390 27113 27173 2
1000000390 27516 27173 1
1000000390 00113 27173 0
1000000390 27748 27173 5
SELECT * FROM Inventory
WHERE ProductNumber='1000000390'
AND ParentAccountNumber=(SELECT TOP 1 parentaccountnumber FROM Inventory
WHERE accountnumber='27748')
这是可能的纯LINQ语法?我是否需要使用扩展方法语法?
感谢, -Keith
好极了!谢谢。 – Keith 2010-02-08 22:38:00