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 @  http://www.microsoft.com/downloads/details.aspx?FamilyID=a71060eb-454e-4475-81a6-e9552b1034fc&displaylang=en

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

 image 

 

 

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

image

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

image

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

image

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.

image 

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

image

Thanks(Nandri)

SreenivasaRagavan.

No comments: