static void Main(string[] args) { GringottsContext gringotts = new GringottsContext(); gringotts.Database.Initialize(true); try { WizardDeposits deposit = new WizardDeposits { FirstName = "Albus", LastName = "Dumbledore", Age = 150, MagicWandCreator = "Antioch Paverell", MagicWandSize = 15, DepositStartDate = new DateTime(2016, 10, 20), DepositExpirationDate = new DateTime(2020, 10, 20), DepositAmount = 20000.24m, DepositCharge = 0.2m, IsDepositGroup = false }; gringotts.Deposits.Add(deposit); gringotts.SaveChanges(); } catch (DbEntityValidationException ex) { foreach (DbEntityValidationResult dbEntityValidationResult in ex.EntityValidationErrors) { foreach (DbValidationError dbValidationError in dbEntityValidationResult.ValidationErrors) { Console.WriteLine(dbValidationError.ErrorMessage); } } } }
public static void Main() { var context = new GringottsContext(); var uniqueWizardFirstLetters = context.WizzardDeposits .Where(w => w.DepositGroup == "Troll Chest") .Select(w => w.FirstName.Substring(0, 1)) .Distinct() .ToArray(); foreach (var letter in uniqueWizardFirstLetters) { Console.WriteLine(letter); } }
static void Main(string[] args) { var context = new GringottsContext(); StringBuilder content = new StringBuilder(); #region//First Letter //var uniqueFirstLetterGringotts = context.WizzardDeposits //.Where(d => d.DepositGroup == "Troll Chest") //.Select(d => d.FirstName.Substring(0, 1)) //.Distinct() //.OrderBy(d => d); //foreach (var letters in uniqueFirstLetterGringotts) //{ // content.AppendLine($"{letters}"); //} #endregion Console.WriteLine(content); }
static void Main(string[] args) { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; GringottsContext context = new GringottsContext(); //Tasks 1 and 2 Deposits Sum for Ollivander Family var depositGroups = context.WizzardDeposits.Where(x => x.MagicWandCreator == "Ollivander family") .GroupBy(y => new { y.DepositGroup }) .Select(g => new { DepositGroup = g.Key.DepositGroup, Sum = g.Sum(x => x.DepositAmount) }).Where(arg => arg.Sum.Value < 150000) .OrderByDescending(arg => arg.Sum); foreach (var element in depositGroups) { Console.WriteLine($"{element.DepositGroup} - {element.Sum}"); } }
static void Main(string[] args) { WizardDeposit dumbledore = new WizardDeposit() { FirstName = "Albus", LastName = "Dumbledore", Age = 150, MagicWandCreator = "Antioch Peverell", MagicWandSize = 15, DepositStartDate = new DateTime(2016, 10, 20), DepositExpirationDate = new DateTime(2020, 10, 20), DepositAmount = 20000.24m, DepositCharge = 0.2m, IsDepositExpired = false }; var context = new GringottsContext(); context.WizardDeposits.Add(dumbledore); context.SaveChanges(); }
static void Main() { GringottsContext context = new GringottsContext(); WizardDeposits deposit = new WizardDeposits { FirstName = "Stoyan", LastName = "Ivanov", Age = 37, MagicWandCreator = "magic creator", MagicWandSize = 15, DepositStartDate = new DateTime(2016, 10, 20), DepositExpirationDate = new DateTime(2020, 10, 20), DepositAmount = 20000.24m, DepositCharge = 0.2, IsDepositeExpired = false }; User user = new User { Username = "******", Password = "******", Email = "*****@*****.**", Age = 37, IsDeleted = false, RegisteredOn = DateTime.Now }; Album album = new Album() { Name = "FirstAlbum", }; user.Albums.Add(album); //context.WizardDepositses.Add(deposit); context.Users.Add(user); context.SaveChanges(); }