Book Image

WCF 4.5 Multi-Layer Services Development with Entity Framework

By : Mike Liu
Book Image

WCF 4.5 Multi-Layer Services Development with Entity Framework

By: Mike Liu

Overview of this book

<p>WCF is Microsoft's recommended model for building services and Entity Framework is Microsoft’s preferred ORM for accessing underlying data storages. Learning WCF and Entity Framework has become essential and critical for every software developer to survive in this SOA world.<br /><br />WCF and Entity Framework are two powerful yet complex technologies, and there are huge reference tomes out there in the market for these two technologies. With this book, you won’t get overwhelmed or scared away by tons of references; instead, you will be given a simple, easy-to-follow approach to get started. For the code solutions within this book, unlike many other WCF and EF books, where you have just one code snippet after another code snippet, all solutions in this book are fully working and completely finished. These solutions are independent of each other, yet built on top of each other, and get more and more sophisticated as the book progresses, so you can learn more advanced WCF and EF techniques easily and quickly.<br /><br />This book is a step-by-step tutorial to guide you through learning WCF, Entity Framework, LINQ, and LINQ to Entities. You will be guided to create six WCF and Entity Framework solutions from scratch, of which three are multi-layered real-world WCF service solutions, so you will not only be reading, but also be coding through the book, to gain practical experience of WCF and Entity Framework. <br /><br />Various test clients will be associated with each solution and all solutions can be built and run independently of other solutions. Clear instructions and relevant screenshots will make sure you won't get lost in the world of WCF and Entity Framework. Configuration files, host applications, test clients, and WCF services for each solution will also be available for download for you to examine, modify, and debug from the outside in. <br /><br />The book focuses on the essentials of using WCF and Entity Framework, rather than providing a reference to every single possibility. It leaves the reference material online where it belongs, and concentrates instead on practical examples, code, and advice.</p>
Table of Contents (19 chapters)
WCF 4.5 Multi-Layer Services Development with Entity Framework
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating the business logic layer


Now let's create the business logic layer. The steps here are very similar to the steps in Chapter 4, Implementing a WCF Service in the Real World, so you can refer to that chapter for more details.

  1. Right click on the solution item and select Add | New Project.... Add a class library project with the name LINQNorthwindLogic.

  2. Add a project reference to LINQNorthwindDAL and LINQNorthwindBDO to this new project.

  3. Delete the Class1.cs file.

  4. Add a new class file ProductLogic.cs.

  5. Change the new class ProductLogic to be public.

  6. Add the following two using statements to the ProductLogic.cs class file:

    using LINQNorthwindDAL;
    using LINQNorthwindBDO;
  7. Add the following class member variable to the ProductLogic class:

    ProductDAO productDAO = new ProductDAO();
  8. Add the following new method GetProduct to the ProductLogic class:

    public ProductBDO GetProduct(int id)
    {
        return productDAO.GetProduct(id);
    }
  9. Add the following new method UpdateProduct to the ProductLogic class:

    public bool...