Sunday, April 17, 2011

Exposing POCO as OData Service.

OData – Open Protocol Data aka WCF Data Services.

We all know that using EF(Entity Framework) Data model exposing any relational Data source is very very easy.  But here I am going to show how to expose Plain Old CLR Objects as  OData Service.

1) First Create Empty ASP.NET Web Application.

2) Second we need define or create the Entity Classes and we need to define Primary key using DataServiceKey Attribute for each entity as shown below

image

3) Next we need to create the class which exposes the IQueryable properties which returns the collection of Each entity which we created about. here I have defined the Entity as Contact so my IQueryable properties returns collection of Contacts.

image

image

Next we need to add WCF Data Service Template to this project to host the OData Service with the above Entities.

image

Once we added WCF Data Service Template next we need to specify the Entity class name as shown below.  Next we can set the Access rule for Entity

here I set all Entity have read only access.

image

Now run the service you will see the ODataservice with Two Entity exposed .

image

IF we browse the following URL we get  Contacts details http://localhost:52200/WcfDataService1.svc/MyContacts 

image

Nandri(Thanks)

SreenivasaRagavan

Friday, April 15, 2011

Get Silverlight 5.0 Beta

Silverlight 5 continues the pace of rapid innovation, building on Silverlight 4's capabilities in the areas of rich applications and premium media experiences. With over 40 new features, the Silverlight 5 beta highlights dramatic video quality and performance improvements, as well as new capabilities that improve developer productivity

image

Here is the URL where you can download Silverlight 5.0 beta http://www.silverlight.net/getstarted/silverlight-5-beta/

Nandri(Thanks)

Sreenivasaragavan.R

Wednesday, April 6, 2011

Escape Sequence for { in C#

Today there was need for me to print {} char in my console output. I knew there are standard Escape Sequences in C# but I was not aware of Escape Sequence for  {.  when I was binging I found the solution to this problem I just wanted to share with my Blog readers.

image

Nandri(Thanks)

Sreenivasaragavan.