Monday, September 7, 2009

ADO.NET Data Services – Projections[$select query option]

The ADO.NET Data Services Projection feature allows client to query subset of properties of Entity Set. This feature helps to optimize client applications  bandwidth consumption and memory footprint. ADO.NET Data Services URI format by adding the $select query option to enable clients to explicitly define the properties to be returned.

Let’s see this in action.  First download & Installed  ADO.NET Data Services v1.5 CTP2.  Download @

1) First Create ASP.NET Web Application Project.

2) Add ADO.NET Entity Data Model Template to the project. and follow the Wizard  and create our Entity Model which we are going to expose as a Service.

Here i am going to choose Adventure Works Database Contact Table as my Data source. image




3) Now we need to Add ADO.NET Data Service V1.5 CTP2 template 


4) Now we need make  changes to  the  .SVC  as shown below. And browse the .Svc in browser


Here is the screenshot shows our ADO.NET service is Up and Running with Contact Entity set. 


when you browse the following http://localhost:1888/AW.svc/Contact URL you get all Records with all properties of the contact Entity set as shown below.


Now we are coming actual part of this Blog post. Now let’s use projection feature to query Contact Entity Set  FirstName, LastName &EmailAddress Properties.

Here is the URI format http://localhost:1888/AW.svc/Contact?$select=FirstName,LastName,EmailAddress and the result of the this query is




No comments: