one to many complete #2

Merged
clement.lesme merged 1 commits from part3 into master 1 year ago

@ -14,6 +14,7 @@ using (var context = new LibraryContext())
Console.WriteLine("Insertion\n"); Console.WriteLine("Insertion\n");
books = await myStub.booksStub(); books = await myStub.booksStub();
persons = await myStub.personsStub();
// Ajoute chaque person à la base de données de manière asynchrone // Ajoute chaque person à la base de données de manière asynchrone
foreach (var person in persons) foreach (var person in persons)
@ -21,6 +22,7 @@ using (var context = new LibraryContext())
await context.PersonsSet.AddAsync(person); await context.PersonsSet.AddAsync(person);
} }
await context.SaveChangesAsync();
// Ajoute chaque livre à la base de données de manière asynchrone // Ajoute chaque livre à la base de données de manière asynchrone
foreach (var book in books) foreach (var book in books)

@ -22,7 +22,6 @@ namespace StubbedContextLib
Author = "Lechardeur", Author = "Lechardeur",
Title = "Comment pécho 100% garanti", Title = "Comment pécho 100% garanti",
Isbn = "696969a", Isbn = "696969a",
PersonEntityId = 1,
}; };
BookEntity book2 = new BookEntity BookEntity book2 = new BookEntity
@ -30,7 +29,8 @@ namespace StubbedContextLib
Id = 2, Id = 2,
Author = "Vianney", Author = "Vianney",
Title = "Gros", Title = "Gros",
Isbn = "0015150" Isbn = "0015150",
PersonEntityId = 1,
}; };
BookEntity book3 = new BookEntity BookEntity book3 = new BookEntity
@ -38,7 +38,8 @@ namespace StubbedContextLib
Id = 3, Id = 3,
Author = "Khéna", Author = "Khéna",
Title = "Khéna; un homme, un livre", Title = "Khéna; un homme, un livre",
Isbn = "666666b" Isbn = "666666b",
PersonEntityId = 1,
}; };
//Ajout des livres //Ajout des livres

Loading…
Cancel
Save