This is a mirror of official site: http://jasper-net.blogspot.com/

Reading Data from WCF Data Service in Silverlight 4

| Tuesday, June 14, 2011
As part of .NET Framework 4.0 and Windows Communication Foundation (WCF) 4.0, ADO.NET Entity Framework integration is provided using WCF Data Services. The WCF Data Services exposes entity data (provided by ADO.NET EF) as a data service.

WCF Data Services enables the creation and consumption of OData services for the web. Note that WCF Data Service was formerly known as ADO.NET Data Services.

To design a WCF Data Service, we need to do the following:

Design the Data Model using ADO.NET EF:

This is done with the help of ADO.NET Entity Framework. This is based upon Object Relational Mapping (O-R-M) where we get the CLR objects mapped with the database table.
In this case, the query can be fired directly on the mapped objects which returns an instance of IQueryable interface.
Using this mapping, it is possible for us to perform Create, Read, Update and Delete operations on the Database.
Create a Data Service:

Here the DataService<T> class is used as a base for exposing the Data Service. It contains the entry point for the entity container which is defined by the Data Model.
Configure Access Rules for the Data Service:

This is the most important step. Here you need to configure the Data Service which defines AccessRules for entities defined in the Data Model.
Based upon the operation you want to perform, the access rule must be specified.
DataServiceConfiguration class is used for Data Service configuration and setting Access Rules.
In this article demonstration, I have used Sql Server 2008 and the Database is ‘Company’ with the following table:

Posted via email from Jasper-net

0 comments: