public void GivenTheFollowingBooks(Table table) { var db = new BookShopEntities(); foreach (var row in table.Rows) { Book book = new Book { Author = row["Author"], Title = row["Title"], Price = Convert.ToDecimal(row["Price"]) }; if (table.Header.Contains("Id")) ReferenceBooks.Add(row["Id"], book); db.AddToBooks(book); } db.SaveChanges(); }
/// <summary> /// Create a new Book object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="author">Initial value of the Author property.</param> /// <param name="title">Initial value of the Title property.</param> /// <param name="price">Initial value of the Price property.</param> public static Book CreateBook(global::System.Int32 id, global::System.String author, global::System.String title, global::System.Decimal price) { Book book = new Book(); book.Id = id; book.Author = author; book.Title = title; book.Price = price; return book; }
/// <summary> /// Deprecated Method for adding a new object to the Books EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToBooks(Book book) { base.AddObject("Books", book); }