說我有這些類:如何使用LINQ合併樹(和總數)?
public class Option
{
public int OptionID { get; set; }
public bool IsSelected { get; set; }
}
public class Product
{
public int ProductID { get; set; }
public int Quantity { get; set; }
public List<Option> Options { get; set; }
}
比方說,這將是添加一些Product
對象爲List<Product>
2x Product 1 OptionID 1 OptionID 1 OptionID 2 OptionID 2
2x Product 1 OptionID 1 OptionID 1 OptionID 2 OptionID 2
後,我的結果,我怎樣才能將這些結果變成使用LINQ(lambda)的單個結果,其中IsSelected = true
?
4x Product 1 4x OptionID 1 4x OptionID 2
您的最終目標不適用於您當前的'ChartItems'類。 – 2014-10-26 22:59:11
在你的'ChartItems'類中,'Quantity'是否代表'Product'或者'Option'的數量? – 2014-10-26 23:03:58
在你的'ChartItems'類中,'List OptionID'就是所有選擇的'OptionID'值的列表。 –
2014-10-26 23:05:43