Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Linq to REST library for C#

Tags:

rest

c#

linq

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"
like image 855
gimpy Avatar asked May 16 '12 08:05

gimpy


People also ask

Is LINQ for C# only?

LINQ (Language Integrated Query) is uniform query syntax in C# and VB.NET to retrieve data from different sources and formats. It is integrated in C# or VB, thereby eliminating the mismatch between programming languages and databases, as well as providing a single querying interface for different types of data sources.

Is LINQ Faster C#?

It is slightly slower It's good to be aware of any performance tradeoff that might occur when you use LINQ to improve the readability of your code. And if you'd like to measure the performance difference, you can use a tool like BenchmarkDotNet to do so.

Does C++ have something like LINQ?

C++ Integrated Query (CINQ, pronounced “sink”) is a C++ implementation of Microsoft's Language Integrated Query (LINQ).

What is REST API in C#?

REST in Web API stands for REpresentation State Transfer. REST is the combination of a couple of principles that must be followed by the Web API. REST Principles examples - URL Structure HTTP Verbs Status Code Stateless Etc.


2 Answers

I did find one eventually in Linq2Rest (also a NuGet) which seems to fit the bill. Doesn't support OAuth but would be possible to build this in.

like image 174
gimpy Avatar answered Oct 16 '22 12:10

gimpy


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...

like image 20
Brunner Avatar answered Oct 16 '22 13:10

Brunner