Exemple #1
0
 private static void AddAuthor(Authors author)
 {
     using (LibraryEntities db = new LibraryEntities())
     {
         db.Authors.Add(author);
         db.SaveChanges();
         Console.WriteLine("New author added:" + author.LastName);
     }
 }
Exemple #2
0
 static void AddBook(Books book)
 {
     using (LibraryEntities db = new LibraryEntities())
     {
         Books a = db.Books.FirstOrDefault(x => x.Title == book.Title);
         if (a == null)
         {
             db.Books.Add(book);
         }
         db.SaveChanges();
         Console.WriteLine("New book added:" + book.Title);
     }
 }