ramlicious Blogs by Tina & Prabhu

September 14, 2011

Using OData Services

Filed under: C#,OData,Visual Studio,WCF — Prabhuram @ 7:26 am

After writing WCF Data Services with an example (OData Sample), I realized that I could have showed the service that we just created with an example by calling the Data Service from a console application, so I created a console application and then added a service reference to the .svc source and then simply able to call the data service.

    class Program
    {
        static void Main(string[] args)
        {
            foreach (var p in new MusicAlbumService(new Uri("http://localhost/ODataSampler.Web/MusicAlbum.svc/")).Albums)
                System.Console.WriteLine(p.Name);
            System.Console.ReadKey();
        }
    }

How easy is that!!

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress