Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(isDbEmpty("books"))
- {
- using (StreamReader r = new StreamReader("Books.json"))
- {
- string json = r.ReadToEnd();
- List<Book> Books = JsonConvert.DeserializeObject<List<Book>>(json);
- foreach(var b in Books)
- {
- _db.Books.Add(new Book{
- Title = b.Title,
- AuthorFirstName = b.AuthorFirstName,
- AuthorLastName = b.AuthorLastName,
- PublishDate = b.PublishDate,
- ISBN = b.ISBN
- });
- }
- _db.SaveChanges();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement