Databases Reference
In-Depth Information
8.
What you need to do now is create the data service on top of your data model. In Solution
Explorer right-click the web application and select Add; then select New Item. In the Add
New Item dialog, select the Web category, and then scroll down the list of templates and
select the WCF Data Service template. Enter a name of AWDataService and then click Add,
as shown in Figure 5-10 .
Figure 5-10. Adding a WCF Data Service to the Solution
When the ADO.NET Data Service is added to your project, the associated .cs file will automatically be displayed in
the IDE. As you can see, the ADO.NET Data Service template has generated for you the beginnings of your data service.
Connecting the Service to the Model
Now you need to wire up your data service to your data model so that the service knows where to get its data. You
know where to do this, because as you can see in the code it tells you where to enter that information. Thus, change
the line:
public class AWDataService : DataService< /* TODO: put your data source class name here */ >
To:
public class AWDataService : DataService< AdventureWorks2012Entities >
Wiring up your data service to the model is as simple as that. Believe it or not, you're ready to test your service.
However, let's finish what you need to do on this page. By default, the WCF Data Service is secured. The WCF Data
Service needs to be told explicitly which data you want to see. The instructions in the code tell you this, as you can see
in code in the InitializeService method. Some examples are even provided in the comments to help you out.
 
Search WWH ::




Custom Search