Book Image

WCF Multi-layer Services Development with Entity Framework - Fourth Edition

By : Mike Liu
Book Image

WCF Multi-layer Services Development with Entity Framework - Fourth Edition

By: Mike Liu

Overview of this book

Table of Contents (20 chapters)
WCF Multi-layer Services Development with Entity Framework Fourth Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
2
Hosting the HelloWorld WCF Service
Index

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...