Database Reference
In-Depth Information
Figure 10-16. Mapping the stored procedures to the Insert, Update, and Delete actions for the DVD entity
How It Works
We created the stored procedures for the Insert, Update, and Delete actions for both the Book and DVD entities
and imported them into the model. Once we have these stored procedures in the model, we mapped them to the
corresponding actions, being careful to map the Result Column Binding for the Insert action to the ProductId
property. This ensures that the store generated key for the Product is mapped to the ProductId property.
The Table per Hierarchy inheritance is supported by the implementation of the Insert stored procedures. Each
of them inserts the correct ProductType value. Given these values in the tables, Entity Framework can correctly
materialize the derived entities.
The code in Listing 10-27 demonstrates inserting, updating, deleting, and querying the model.
Listing 10-27. Exercising the Insert, Update, and Delete Actions
using (var context = new EF6RecipesContext())
{
var book1 = new Book { Title = "A Day in the Life",
Publisher = "Colorful Press" };
var book2 = new Book { Title = "Spring in October",
Publisher = "AnimalCover Press" };
 
Search WWH ::




Custom Search