static void Main(string[] args) { var context = new GringottsContext(); //DepositsSumForOllivanderFamily(context); DepositsFilter(context); }
static void Main(string[] args) { var context = new GringottsContext(); var wiz = context.WizzardDeposits.Where(w => w.MagicWandCreator == "Ollivander family").Select(d => new { d.DepositGroup, d.DepositAmount }).ToList(); foreach (var w in wiz) { foreach (var d in w.DepositGroup) { d.s } Console.WriteLine($"{w.DepositGroup} - {w.DepositAmount}"); } }
private static void DepositsSumForOllivanderFamily(GringottsContext context) { var depositGroups = context.WizzardDeposits .Where(x => x.MagicWandCreator == "Ollivander family") .GroupBy(x => x.DepositGroup, x => x.DepositAmount, (key, g) => new { DepositGroupName = key, DepositsAmounts = g.ToList() }); foreach (var depositGroup in depositGroups) { Console.WriteLine($"{depositGroup.DepositGroupName} - {depositGroup.DepositsAmounts.Sum()}"); } }