private async Task AddBooksAsync() { using (BooksContext context = new BooksContext()) { Book book = new Book { Title = "Professional C# 5 and .NET 4.5.1", Publisher = "Wrox Press" }; Book book1 = new Book { Title = "Professional C# 2012 and .NET 4.5", Publisher = "Wrox Press" }; Book book2 = new Book { Title = "JavaScript for Kids", Publisher = "Wrox Press" }; Book book3 = new Book { Title = "Web Design with HTML and CSS", Publisher = "Wrox Press" }; context.AddRange(book, book1, book2, book3); // context.Add(book); int records = await context.SaveChangesAsync(); Console.WriteLine($"{records} record added"); } }
private async Task AddBooksAsync() { using (var context = new BooksContext()) { var b1 = new Book { Title = "Professional C# 5 and .NET 4.5.1", Publisher = "Wrox Press" }; var b2 = new Book { Title = "Professional C# 2012 and .NET 4.5", Publisher = "Wrox Press" }; var b3 = new Book { Title = "JavaScript for Kids", Publisher = "Wrox Press" }; var b4 = new Book { Title = "Web Design with HTML and CSS", Publisher = "For Dummies" }; var b5 = new Book { Title = "Conflict Handling", Publisher = "Test" }; context.AddRange(b1, b2, b3, b4, b5); int records = await context.SaveChangesAsync(); WriteLine($"{records} records added"); } WriteLine(); }
private async Task AddBooksAsync() { using (var context = new BooksContext()) { var b1 = new Book { Title = "Professional C# 5 and .NET 4.5.1", Publisher = "Wrox Press" }; var b2 = new Book { Title = "Professional C# 2012 and .NET 4.5", Publisher = "Wrox Press" }; var b3 = new Book { Title = "JavaScript for Kids", Publisher = "Wrox Press" }; var b4 = new Book { Title = "Web Design with HTML and CSS", Publisher = "For Dummies" }; var b5 = new Book { Title = "Conflict Handling", Publisher = "Test" }; context.AddRange(b1, b2, b3, b4, b5); int records = await context.SaveChangesAsync(); WriteLine($"{records} records added"); } WriteLine(); }
public async Task AddBooksAsync() { var b1 = new Book { Title = "Professional C# 5 and .NET 4.5.1", Publisher = "Wrox Press" }; var b2 = new Book { Title = "Professional C# 2012 and .NET 4.5", Publisher = "Wrox Press" }; var b3 = new Book { Title = "JavaScript for Kids", Publisher = "Wrox Press" }; var b4 = new Book { Title = "Web Design with HTML and CSS", Publisher = "For Dummies" }; _booksContext.AddRange(b1, b2, b3, b4); int records = await _booksContext.SaveChangesAsync(); WriteLine($"{records} records added"); }