2
我试图找到一个远来概括所有的数量为特定方法(所有成分)为一个值来获得总量如何在LINQ中对另一个字段进行分组?
假设我有以下数据集:
RecipeName IngredientName ReceiptWeight
Food1 Ingredient1 5
Food1 Ingredient2 2
Food2 Ingredient1 12
Food2 Ingredient3 1
而且我希望得到如下:
RecipeName ReceiptWeight
Food1 7
Food2 13
我到目前为止的代码是:
Grouping =
(
from data in dataset
group data by data.RecipeName into recipeGroup
let fullIngredientGroups = recipeGroup.GroupBy(x => x.IngredientName)
select new ViewFullRecipe()
{
RecipeName = recipeGroup.Key,
ReceiptWeight = ????
如何获得RecipeWeight的值? 谢谢,