Chapter 13. Working with Stored Procedures When Function Mapping Won’t Do
In Chapter 6, you learned about function mapping for stored procedures in the Entity Data Model (EDM). Mapping insert, update, and delete stored procedures to entities is the simplest way to use stored procedures in the EDM. But the scenarios in Chapter 6 cover only a narrow scope of the types of stored procedures many developers leverage in their applications.
Although version 1 of the Entity Framework has plenty of support for stored procedures, the Designer doesn’t support everything the model can do, which in some cases makes implementing stored procedures somewhat taxing.
This chapter will cover a number of different ways to implement
stored procedures beyond the function mapping you already performed in the
Designer that overrides the SaveChanges
behavior. These additional implementations will create functions that you
can call directly in your code.
In addition to implementing stored procedures from your database, you’ll also learn how to create native stored procedures directly in your model.
The first part of the chapter will focus on stored procedures that are used for querying the database. The latter part of the chapter will address stored procedures for performing inserts, updates, and deletes in your database.
Does the Procedure Line Up with an Entity?
In previous chapters, you learned to use functions for database
stored procedures—for example, the InsertPayment
and CustomersbyState
functions, which ...
Get Programming Entity Framework now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.