In the previous chapter, we modeled and generated the source code for a WCF service using Service Factory. Although the service interface code is generated based on the Contract Models, no business entity, or data access layer, or business logic layer code has been generated at all. The Modeling Edition of the Service Factory doesn't give any tool to automatically generate code for them. You may recall that with the previous version's Service Factory, you could generate business entities from a database, but this is not the case for this version.
In this chapter, we will manually add code for these projects, so that we have a completed WCF service. We will also generate the host application and test client using Service Factory, and then test the WCF service.
We will follow these steps to complete the EasyNorthwind
service in this chapter:
First, we will create our business entities for the service. Follow these steps to add the product entity to the project:
Now, customize the ProductEntity.cs
file:
The final ProductEntity
class file should look like this:
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace MyWCF.EasyNorthwind.BusinessEntities { public class ProductEntity { public int ProductID {get; set;} public string ProductName {get; set;} public string QuantityPerUnit {get; set;} public decimal UnitPrice {get; set;} public int UnitsInStock {get; set;} public int ReorderLevel {get; set;} public int UnitsOnOrder {get; set;} public bool Discontinued { get; set; } } }
Build the business entities project, to make sure that there is no build error.