Adding a Service Layer
In this section, we will add a Service Layer to our design.
Tip
Decision Point: Service Layer
You should only introduce a service layer in your project if it's needed. Each new architectural feature we will cover in this text will provide benefits for a cost. It's extremely important that you are familiar with the trade-offs and only add what you need. If you are writing an internal tool, adding a Service Layer might be overkill and provide no ROI to your project.
To add a Service Layer to Northwind, perform the following steps:
Add a new WCF Service Library project to your solution called
Northwind.Service
and delete the filesIService1.cs
andService1.cs
,from the project.Add a project reference from
Northwind.Service
toNorthwind.Data
and a .NET reference fromSystem.Data.Entity
toNorthwind.Data
.Add a file called
Customer.cs
toNorthwind.Service
and update it, as shown in the following code:using System.Runtime.Serialization; namespace Northwind.Service { [DataContract...