Calling a stored procedure
Calling a stored procedure is different from querying a table or a view because a stored procedure can't be called without the proper preparation. A function import has to be added for the stored procedure and its result set has to be mapped. The modeling of a stored procedure is also different from modeling a table or a view. In the following sections, we will learn how to call a simple stored procedure, map the returned result of a stored procedure to an entity class, and create a new entity for the result set.
We will reuse the same application that we used in the previous chapter and add more methods to the program.
Mapping a stored procedure to a new entity class
First, we will try to call a simple stored procedure. In the sample database, there is a stored procedure called Ten Most Expensive Products
. We will call this stored procedure to get the top ten most expensive products.
Adding a stored procedure to the model
Before we can call a stored procedure, we need...