Alex Rivera | Logout

Is there a Linq to REST library for C#

Asked 2012-05-16T08:18:51.943
10

I have an Linq Expression and I want to convert it to a querystring for REST, i.e.

public IQueryable<Organisation> Organisations;

...
var organisations = Organisations.Where(x => x.Name == "Bob");

becomes

http://restservice.com/Organisations?$filter=Name eq "Bob"
Edit
Report

3 Answers

2

If you are control over the datasource, it's OData what you are looking for.

A google-searched brought HttpEntityClient up, although I don't have any experience with it but it looks useful.

I guess you could also write your own implementation, because frankly, rest-apis don't have to follow a certain standard when it comes to filtering, ordering etc...

answered 2012-05-16T08:23:04.240
1

I found that DataServiceContext developed by Microsoft works much smoother than Linq2Rest and HttpEntityClient third party libraries mentioned here. Documentation is also much better. The downside is that DataServiceContext works with XML only (no JSON). But both WebAPI OData REST services and WCF Data Services can return XML, if it requested by a client in HTTP header. Because XML support takes no additional development work, lack of JSON support is unlikely to be an issue.

There are LINQ to REST examples using DataServiceContext: http://msdn.microsoft.com/en-us/library/windowsazure/dd894039.aspx

answered 2013-05-25T03:03:28.530
0

try Odata

The Open Data Protocol (OData) is a Web protocol for querying and updating data that provides a way to unlock your data and free it from silos that exist in applications today. OData does this by applying and building upon Web technologies such as HTTP, Atom Publishing Protocol (AtomPub) and JSON to provide access to information from a variety of applications, services, and stores. The protocol emerged from experiences implementing AtomPub clients and servers in a variety of products over the past several years. OData is being used to expose and access information from a variety of sources including, but not limited to, relational databases, file systems, content management systems and traditional Web sites.

EDIT 1: take a look at here also: http://paulhammant.com/2012/02/13/client-side-mvc-frameworks-compared/

answered 2012-05-16T08:23:18.747

Your Answer