Is it useful to use OData?

Understanding in advance the reservation that "just because the opportunity offered does not make it a good idea" ...

In appearance, OData-compatible Signatures require IQueryable to return .

FOR EXAMPLE:

[Queryable] public IQueryable<MyModel> Get() { return _repo.GetAll().AsQueryable(); } 

However, many articles in the recent and not quite recent past describe IQueryable as:

MY QUESTION :
Do you feel the capabilities of IQueryable and OData above problems?

Answering, I would expect people to talk about:

  • Why or why not?
  • When should you use it?
  • Are you using only some of the WebAPI calls ... or for all WebAPI calls?
  • What about individual models that are not IEnumarable objects?

... such things.

BACKGROUND : I ask not only because of the above elements. But also because OData is being sold to us as an โ€œindustry standard,โ€ not a tool in your toolbox. Thus, implementing this will fundamentally change the return for our WebAPI calls (where I work now). We would have to go from our own IResult backlink (which is very useful) to IQueryable, which seems to have problems (but may also prove useful).

IRESULT example:
At a minimum, our reverse signatures have changed dramatically. And, as I was told, a WebAPI call that implements OData does not work, changing the "C instance" to "IQueryable Instance" (which makes sense).

 public interface IResult<C> { [JsonProperty(PropertyName = "hasErrors")] bool HasErrors { get; } [JsonProperty(PropertyName = "errors")] IList<String> Errors { get; } [JsonProperty(PropertyName = "instance")] C Instance { get; set; } } 
+8
c # odata asp.net-web-api
source share
1 answer

Support for OData queries using the Web API does not require an IQueryable<T> . Having an IQueryable<T> allows you faster and with less code. IQueryable<T> has the necessary abstractions to translate an incoming OData query into a LINQ query. The framework already defines it, and there is rich support at various ends for it, like Entityframework, NHibernate, Linq2Objects, RavenDB, Linq2OData, etc. So, we decided to have rich IQueryable<T> support with web API. Agreed, IQueryable<T> is a huge interface and provides much more than what is needed for OData queries. But this is what comes for free :).

However, we have good support through ODataQueryOptions<T> for a case other than IQueryable. Check out my blog post about it here.

In addition, you mix OData query semantics with OData. Rich query support is only one part of OData. OData builds on top of HTTP and has various useful features such as

  • Well thought out application of both the best REST and HTTP methods.
  • Unambiguos presents your resources in json and xml.
  • $ metadata.
  • The standard way to describe relationships.
  • A rich query that supports forecasts, filtering, paging under client control and server-managed paging (link on the next page).
  • Great ecosystem .
+3
source share

All Articles