Caching Data in Web API

The solution I ended up using involved MemoryCache in the System.Runtime.Caching namespace. Here is the code that ended up working for caching my collection: //If the data exists in cache, pull it from there, otherwise make a call to database to get the data ObjectCache cache = MemoryCache.Default; var peopleData = cache.Get(“PeopleData”) as List<People>; if … Read more

What is the difference between OData, JsonAPI, GraphQL?

OData is a similar specification to JSON API. Both of them describe a standard protocol for creation and consumption of RESTful APIs. GraphQL is a totally different approach to API design and specifies a different way of querying API resources. OData: Designed and developed at Microsoft since 2007, standardized by the OASIS consortium. The latest … Read more

odata – combining $expand and $select

After going through a lot of time on this, I finally got the answer. We can nest select within expand using ; as a separator, something like odata/Products(8)?$expand=choices($select=col1,col2;$expand=item($select=name)) This is documented in the OData v4 $expand documentation. The documentation also lists other useful examples such as Categories?$expand=Products($filter=DiscontinuedDate eq null) Categories?$expand=Products/$count($search=blue)

OData $filter with multiple predicates

You can definitely combine predicates in the $filter. For example: /People?$filter=endswith(LastName,’Smith’) and startswith(FirstName,’Mary’) For details around supported operators and such please see this page: http://www.odata.org/documentation/odata-version-2-0/uri-conventions#FilterSystemQueryOption Currently OData doesn’t have a way to express the question “People which have at least one address”. Depending on your data it might be feasible to download all People fulfilling … Read more

OData Python Library available?

i am the author of the library at http://code.google.com/p/odata-py/ it’s still in its early stages but it provides the most basic functionalities (create, read, update). Don’t hesitate to drop a message if you see a bug or want to contribute 😉

OData: Date “Greater Than” filter

Figured this out. OData V2 out-of-the-box returns dates out of SQL in JSON Date format like so: /Date(1338282808000)/ However, in order to use a date as a filter within an OData call, your date has to be in EDM format, looking like this: 2012-05-29T09:13:28 So, I needed to get the date from my initial OData … Read more

OData Error: The query specified in the URI is not valid. The property cannot be used in the query option

From the docs 13.1 Model Bound Attributes: Now the default setting for WebAPI OData is : client can’t apply $count, $orderby, $select, $top, $expand, $filter in the query, query like localhost\odata\Customers?$orderby=Name will failed as BadRequest, because all properties are not sort-able by default, this is a breaking change in 6.0.0 So, we now need to … Read more