BooksSample.Program.AddBooksAsync C# (CSharp) Метод

AddBooksAsync() приватный Метод

private AddBooksAsync ( ) : System.Threading.Tasks.Task
Результат System.Threading.Tasks.Task
        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();
        }

Usage Example

        static void Main()
        {
            var p = new Program();
            p.AddBookAsync("Professional C# 6", "Wrox Press").Wait();
            p.AddBooksAsync().Wait();
            p.ReadBooks();
            p.QueryBooks();
            p.UpdateBookAsync().Wait();

            ConflictHandlingAsync().Wait();

            p.DeleteBooksAsync().Wait();

        }
All Usage Examples Of BooksSample.Program::AddBooksAsync