我需要將Sum值加入到列表中的列表中。 例如,我有類A和B,和B具有值我要總結:Linq2Sql:加入列的總和
class A
{
//props
}
class B
{
//props
decimal ValToSum { get; set; }
}
A有A與B的關係,以使每一可以有很多燒烤加盟。
而且我從我的數據上下文的列表:
IEnumerable<A> myList;
// obtain myList from DataContext
現在我要總結從A.
喜歡的東西的加入導致每一個B的ValToSum屬性:
myList.Bs.Sum(x => x.ValToSum);
如何訪問與myList中相關的所有Bs列表?
完美工作。 – 2012-01-15 23:09:41