Will OData eliminate the need for standard web services? Here is a simple example of how OData works. This example does not use a database connection so that you can easily see just the OData parts.

In Visual Studio 2010, create a New Project.

Make an Empty ASP.NET Web Application.

Add a New Item...

Add a WCF Data Service
Paste in the following code:
using System;
using System.Collections.Generic;
using System.Data.Services;
using System.Data.Services.Common;
using System.Linq;
using System.ServiceModel.Web;
using System.Web;
namespace ODataSample
{
public class Service : DataService<SampleDataSource>
{
// This method is called only once to initialize service-wide policies.
public static void InitializeService(DataServiceConfiguration config)
{
config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
config.MaxResultsPerCollection = 100;
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
}
}
[EntityPropertyMappingAttribute("CustomerName", SyndicationItemProperty.Title, SyndicationTextContentKind.Plaintext, true)]
[DataServiceKey("CustomerID")]
public class CustomerRecord
{
public int CustomerID { get; set; }
public string CustomerName { get; set; }
public string CustomerEmail { get; set; }
public string CustomerNotes { get; set; }
public DateTime CustomerLastContact { get; set; }
}
public class SampleDataSource
{
private readonly List<CustomerRecord> _sampleCustomerRecordList;
public SampleDataSource()
{
_sampleCustomerRecordList = new List<CustomerRecord>();
for (int i = 0; i < 100; i++)
{
CustomerRecord CR = new CustomerRecord();
CR.CustomerID = i;
CR.CustomerName = string.Format("FirstName{0} LastName{1}", i.ToString(), i.ToString());
CR.CustomerEmail = string.Format("Email{0}@{1}.com", i.ToString(), i.ToString());
CR.CustomerNotes = string.Format("Notes {0}. Notes {1}", i.ToString(), i.ToString());
CR.CustomerLastContact = DateTime.Now.AddDays(-10000).AddHours(i);
_sampleCustomerRecordList.Add(CR);
}
}
public IQueryable<CustomerRecord> SampleCustomerData
{
get
{
return _sampleCustomerRecordList.AsQueryable();
}
}
}
}
Save and build the site.

Right-click on the Service in the Solution Explorer

You will see the service.
Download and install LinqPad (http://LinqPad.com)

In LinqPad, add a new connection

Make a WCF Data Services connection

Paste in the URL to the service

You will see the Entities in the service

You can execute queries against the OData service. The query above gets the first 20 records that match the query.

The query above gets the second page.
OData Security
To secure your OData points see:
Simple Example To Secure WCF Data Service OData Methods
Download:
ODataSample/ODataSample.zip