OData
Create and consume RESTful APIs in a simple and standard way
Latest posts
Enabling Endpoint Routing in OData
Few months ago we announced an experimental release of OData for ASP.NET Core 3.1, and for those who could move forward with their applications without leveraging endpoint routing, the release was considered final, although not ideal. But for those who have existing APIs or were planning to develop new APIs leveraging endpoint routing, the OData 7.3.0 release didn't quiet meet their expectations without having to disable endpoint routing. Understandably this was quite a trade off between leveraging the capabilities of endpoints routing versus being able to use OData. Therefore in the past couple of months t...
Integrating Cosmos DB with OData (Part 3)
Sometimes requiring to build an entire ASP.NET Core application just for the purpose of exposing a RESTFul API endpoint to give your API consumers the ability to query, filter and order the data could be a bit of an overhead, especially if you are not planning on adding in any additional business logic between your data and it's consumers. It's not also a very cost effective solution when it comes to the development effort, maintenance, infrastructure and all the bells and whistles that accompany developing a custom ASP.NET Core API. If that's the case for your task, Cosmos DB offers native support for ODat...
$select Enhancement in ASP.NET Core OData
The release of ASP.NET Core OData v7.3 brings a ton of improvements to $select functionality. In this article, I’d like to introduce some of the new features of $select and its usages in combination with other query options like $filter, $top, $skip, $orderby, $count and $expand. This tutorial assumes that you already have the knowledge to build an ASP.NET Core Web Application service using ASP.NET Core OData NuGget package. If not, start by reading ASP.NET Core OData now Available and refer to the sample project used in this article. Let’s get started. Data Model As mentioned, we are going to skip the steps ...
Experimenting with OData in ASP.NET Core 3.1
A lot of developers have asked me recently about OData compatibility with ASP.NET Core 3.0 and again with .NET Core 3.1 after it’s very recent release. This demand became more and more critical with the recent announcement from the .NET team around .NET Core 2.2 reaching the end of its life on Dec 23rd of this year. And because of all of that, the OData team at Microsoft have been working diligently in the last few months to ensure a stable release of OData that supports .NET Core 3.1 makes it out to the public as soon as possible. And while the final release might take a bit longer to be production-read...
Optimizing Web Applications with OData $Select
OData as an API technology comes in with so many options that gives API consumers the power to shape, filter, order and navigate through the data with very few lines of code. In my previous articles I talked in details about how to enable OData on your existing ASP.NET Core API using the EDM model, in addition to that I have provided a code example for you to be able to test the capabilities of OData on your own machine. In this article, I suggest you keep the very same source code handy to learn more about one of the most powerful query options of OData, which is $select Introduction to OData $Select O...
Customize Control Information for full metadata requests in odata.net
Background OData supports three metadata levels for the JSON format, namely - No Metadata as the name suggests does not include control information other than nextLink and count. Minimal metadata responses usually include context, etag, deltalink etc. whereas full metadata responses contain all the control information like navigationLink, assciationLink, readLink, mediaReadLink etc. ODataMetadataSelector With odata.net >=7.6.1, it will be possible to customize what metadata gets written out. A new class, ODataMetadataSelector is introduced which exposes methods that can be overridden to add...
Using SkipToken for Paging in Asp.Net OData and Asp.Net Core OData
Loading large data can be slow. Services often rely on pagination to load the data incrementally to improve the response times and the user experience. Paging can be server-driven or client-driven: Client-driven paging In client-driven paging, the client decides how many records it wants to load and asks the server for that many records. That is achieved by using $skip and $top query options in conjunction. For instance, if a client needs to request 10 records from 71-80, it can send a similar request as below: However, this is problematic if the data is susceptible to change. In case of a deletion in betwee...
Integrating Cosmos DB with OData (Part 2)
In the first article of this series, we talked about integrating Cosmos DB with ASP.NET Core application powered by OData using a pre-built solution that was using Cosmos Client to run full CRUD operations. But that's not the only way we can work with Cosmos DB from ASP.NET Core - there are two more approaches that we could follow to work with this great technology. In this article we are going to leverage the power of the Entity Framework to communicate with Cosmos DB then add OData on top of that to supercharge our API with even more functionality that makes querying, filtering and navigating the data in ...
Integrating Cosmos DB with OData (Part 1)
We talked in previous articles about the pluggability of OData with any storage technology regardless of its schema, whether it’s a SQL-based storage, NoSQL, In-Memory or simply a file on a hard-drive. This power of OData enables developers to work with powerful, planet-scale storage technologies such as Cosmos DB. In this article we are going to deep dive into one of three ways you can integrate Cosmos DB with OData but before we start, let’s talk a little bit about Cosmos DB, it’s capabilities and why it’s important to be able to expose that storage powerful through an API with OData. What is C...