I recently played around with the ASP.NET WebAPI, including some Html-Pages displaying results, trying out OData queries in the browser/fiddler etc. and im really impressed and so far everything works great.
But…
Now im trying to build a reusable .Net client library which provides easy access to all methods the WebAPI exposes.
I´ve tried to do this via Linq2Rest (great IQueryable-Interface!) and with implementing Wrappers myself with the HttpClient.
My Problems with Linq2Rest:
- Its not from Microsoft, and i fear there will be a lot of changes by Microsoft which won´t be reflected in Linq2Rest at some point.
- Also i don´t really see how to call Put/Delete/Post with Linq2Rest, having a HttpClient inside every “Linq2Rest-Context” looks very ugly
When trying to implement the client myself with HttpClient i don´t know how to
- Issue calls against a IQueryable-WebAPI-Get without loading every record to the client first (~20000 records is very common in my scenario)
- Avoid writing very similar code vor every “APIController”-Client, in the end i will have about 15-20 Controllers, very similar but returning different “objects”
Thanks for every suggestion…
I am the developer of Linq2Rest and your points are very valid. Linq2Rest was created to add OData support outside of WebAPI. If you are already using WebAPI, then by all means, stick with Microsoft.
It is not from Microsoft, but OData is an open standard, and Linq2Rest is implemented according to the standards document. Being open source has meant that Linq2Rest is able to release more frequently than Microsoft. For this reason, it already supports Any/All queries from the OData 3 spec, which Microsoft currently does not support.
Injecting a client into each context is to make it less restrictive about which services it supports. It is now up to you to define the endpoint. I am thinking about how to support multiple endpoints from a single context.
Currently it does not support PUT/POST/DELETE, but if you post that as a feature request in the project (https://bitbucket.org/jjrdk/linq2rest/issues?status=new&status=open), then it will certainly be added to the pipeline.
EDIT: The latest pre-release adds support for PUT/POST/DELETE operations. The API is currently being tested. If you download versions from 2.5.0.0 then you will find support for it.