Query with OData in SharePoint 2013

OData, i.e. Open Data Protocol, which defines a protocol for the querying and updating of data.
In this blog, we will see the use of oData in ASP.Net.
OData is a REST-based protocol for querying and updating data and is built on standardized technologies such as HTTP, Atom/XML, and JSON.

Microsoft Visual Studio and .NET provide established support for services compliant with the OData specification.

Create a console application in VS 2013.

Right-click on the project and add service reference.

Enter service URL and click on Go, then click on OK


Write below code:

    class Program
        static void Main(string[] args)
            ServiceReference1.SharePointCafe2DataContext dcontext = new ServiceReference1.SharePointCafe2DataContext(new Uri(“http://win:1002/_vti_bin/listdata.svc”));
            dcontext.Credentials = System.Net.CredentialCache.DefaultCredentials;

            foreach(var item in dcontext.Products)

In above code  Products is a SharePoint list.

Please follow and like us:

Leave a Comment