using StubbedContextLib; using Entities; using DbContextLib; using Microsoft.Extensions.Options; // See https://aka.ms/new-console-template for more information Console.WriteLine("Hello, World!"); using (var context = new LibraryContext()) { BookEntity chewie = new BookEntity("B3", "test1", "test1"); BookEntity yoda = new BookEntity ("B4", "test2", "test2"); BookEntity ewok = new BookEntity ("mistake", "test3", "test3"); BookEntity the100 = new BookEntity("the100", "test4", "test4"); context.BooksSet.Add(chewie); context.BooksSet.Add(yoda); context.BooksSet.Add(ewok); context.BooksSet.Add(the100); context.SaveChanges(); } using (var context = new LibraryContext()) { foreach (var n in context.BooksSet) { Console.WriteLine($"Books: {n.ID} - {n.Title}"); } context.SaveChanges(); } using (var context = new LibraryContext()) { var eBooks = context.BooksSet.Where(b => b.Title.StartsWith("t")).First(); Console.WriteLine($"{eBooks.Title} (made by {eBooks.Author})"); eBooks.Title = "Border"; context.SaveChanges(); } using (var context = new LibraryContext()) { Console.WriteLine("Deletes one item from de database"); var impostor = context.BooksSet .SingleOrDefault(n => n.Title.Equals("mistake")); context.Remove(impostor); context.SaveChanges(); }