Book Image

WCF Multi-tier Services Development with LINQ

By : Mike Liu
Book Image

WCF Multi-tier Services Development with LINQ

By: Mike Liu

Overview of this book

<p>WCF is Microsoft's unified programming model for building service-oriented applications. It enables developers to build secure, reliable, transacted solutions that integrate across platforms and interoperate with existing investments. WCF is built on the Microsoft .NET Framework and simplifies development of connected systems. It unifies a broad array of distributed systems capabilities in a composable, extensible architecture that supports multiple transports, messaging patterns, encodings, network topologies, and hosting models. It is the next version of several existing products: ASP.NET's web methods (ASMX), Microsoft Web Services Enhancements for Microsoft .NET (WSE), .NET Remoting, Enterprise Services, and System.Messaging.<br /><br />If you are a C++/C# developer looking for a book to build real-world WCF services, you would have run into the huge reference tomes currently in the market. These books are crammed with more information than you need and most build simple one-tier WCF services. And if you plan to use LINQ in the data access layer, you might buy another volume that is just as huge and just as expensive.<br /><br />Our book is the quickest and easiest way to learn WCF and LINQ in Visual Studio 2008. It is the first book to combine WCF and LINQ in a multi-tier real-world WCF service. Multi-tier services provide separation of concerns and better factoring of code, which gives you better maintainability and the ability to split layers out into separate tiers for scalability. WCF and LINQ are both powerful yet complex technologies from Microsoft, but this book will get you through. The mastery of these two topics will quickly get you started creating service-oriented applications, and allow you to take your first steps into the world of Service Oriented Architecture without getting overwhelmed.<br /><br />Through this book, you will first understand WCF concepts by developing a functional service and apply these techniques to a multi-tier real-world WCF service. You will learn how to use WCF to define the contracts in the service interface layer, Plain Old C# Objects (POCO) to implement business rules in the business logic layer, and LINQ to communicate with the databases in the data access layer. Microsoft pattern and practice Web Service Software Factory is used to create the framework for this WCF service. Concurrency control and distributed transaction support are discussed and tested at the end of the book. Clear step-by-step instructions and precise screenshots will make sure you will not get lost in the new world of WCF and LINQ.</p>
Table of Contents (19 chapters)
WCF Multi-tier Services Development with LINQ
Credits
About the Author
About the Reviewers
Preface
Index

Calling a stored procedure


Calling a stored procedure is different from a table or a view, because a stored procedure can have input parameters, output parameters, and it can return multiple result-sets. It can also return different result-sets dynamically, which makes it even harder to interpret the results. The modeling of a stored procedure is also different from modeling a table or view. In the following sections, we will explain how to call a simple stored procedure, how to map the returned result of a stored procedure to an entity class, and how to handle output parameters, return codes, and multiple result-sets.

We will re-use the same application that we used in the previous chapter, and add more testing methods to the program.

Calling a simple stored procedure

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