Пример #1
0
 static void AddBook(Book book)
 {
     using (Library2Entities db = new Library2Entities())
     {
         db.Book.Add(book);
         db.SaveChanges();
         Console.WriteLine($"New book aded!");
     }
 }
Пример #2
0
 static void AddAuthor(Author author)
 {
     using (Library2Entities db = new Library2Entities())
     {
         db.Author.Add(author);
         db.SaveChanges();
         Console.WriteLine($"New author success added! {author.LastName}");
     }
 }
Пример #3
0
 //Заполнение БД
 static void AddPublisher(Publisher publisher)
 {
     using (Library2Entities db = new Library2Entities())
     {
         Publisher a = db.Publisher.Where(pub => pub.PublisherName == publisher.PublisherName).FirstOrDefault();
         if (a == null)
         {
             db.Publisher.Add(publisher);
             db.SaveChanges();
             Console.WriteLine($"New publisher aded!");
         }
     }
 }