9

ASP.NET MVC4 Beta introduced an easy way to create OData endpoints using WebAPI.

So having the following controller:

public class ValuesController : ApiController
{
    // GET /api/values
    public IQueryable<Document> Get()
    {
        return (new[] { 
            new Document() { Info = "a", Title = "qwe1" }, 
            new Document() { Info = "b", Title = "qwe2" }, }).AsQueryable();
    }
}

I can query the data with url's like: http://localhost:44087/api/values?$filter=Title eq 'qwe1'

Is there a proper .net library that can consume this? So I could do something like:

new WebApiClient("http://localhost:44087/api/values")
                    .Get<Document>().Where(x=>x.Title == "qwe1").ToList()

Without specifying the $filter=Title eq 'qwe1' part manually?

Shaddix
  • 5,901
  • 8
  • 45
  • 86
  • If its a restful odata endpoint, you should be able to add a `Service Reference` from your calling project and VS will generate a proxy class for you. – gideon Mar 06 '12 at 16:16
  • it's not exactly a *restful odata endpoint* like WCF Data Service once. It's queryable like odata endpoint, but has no metadata, so adding a service reference doesn't work – Shaddix Mar 06 '12 at 16:24
  • Ah too bad. Was a guess. – gideon Mar 06 '12 at 16:26

1 Answers1

2

The best thing I found so far is netFX HttpEntityClient. Though, it looks pretty good, it sounds strange that I found nothing comparable from MS..

Shaddix
  • 5,901
  • 8
  • 45
  • 86