Beispiel #1
0
        static void Main(string[] args)
        {
            var context = new GringottsContext();

            //connection string used is .\SQLEXPRESS you can change it in the App.config if you need to.

            //19.Deposits Sum for Ollivander Family
            //DepositGroups(context);

            //20.Deposits Filter
            //DepositFilter(context);
        }
Beispiel #2
0
        private static void DepositGroups(GringottsContext context)
        {
            string wandcrafter = "Ollivander family";

            var depositGroups = context.WizzardDeposits
                                .Where(w => w.MagicWandCreator == wandcrafter)
                                .GroupBy(g => g.DepositGroup)
                                .Select(s => new { Name = s.Key, DepositsAmount = s.Sum(z => z.DepositAmount) })
                                .ToList();

            foreach (var depGroup in depositGroups)
            {
                Console.WriteLine($"{depGroup.Name} - {depGroup.DepositsAmount:F2}");
            }
        }