The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +772K followers.

Follow publication

Member-only story

Clean Architecture — DataTables Support using Partitioned Repository with Cosmos DB

Extend Microsoft doc on pagination, querying, and LINQ by demonstrating server-side processing for DataTables.

Shawn Shi
The Startup
Published in
5 min readNov 21, 2020

UPDATE April 10, 2022: all projects in the GitHub repo have been upgraded to .NET 5.

This article aims to complement the following Microsoft documentations by demonstrating server-side processing for DataTables in an ASP.NET Core API application using Cosmos DB .NET SDK V3 and Partitioned Repository Pattern. Here is an link to the GitHub project.

  • Pagination in Azure Cosmos DB | Microsoft Docs
    This article explains how the queries in Cosmos DB execute and split the query results into multiple pages. When working with Cosmos DB, you probably expect to have a large dataset and splitting query results certainly improve the performance.
  • Tutorial: Query Azure Cosmos DB by using the SQL API
    This article provides sample SQL queries to read data from Cosmos DB. For anyone with a SQL Server background, this article is pretty straightforward to follow. The only follow up question is: how do we write such queries in an ASP.NET Core API application? Since we will not use raw SQL directly in our code, we will use LINQ, which will translate our IQueryable into queries. For Cosmos DB SQL API, IQueryable will be translated into SQL queries.
  • LINQ to SQL translation in Azure Cosmos DB | Microsoft Docs
    This article explains how a LINQ query is translated into a Cosmos DB SQL query, how to properly use IQueryable, and the supported LINQ operators.
Image Credit to Markus Winkler

Why Server-Side Processing?

If you have not used DataTables before, check out Material UI DataTable or JQuery popular plugin called DataTables. A data table is basically an advanced table that supports pagination, sorting, searching, and export functionalities. The easiest way to run DataTables is to load all data to the client/browser, and the DataTables plugin shall take care of the rest. When working with small amount of data, this is amazing since you need almost no effort!

Imagine you have a business that is doing amazing and you have 10 million customers, now you want to build a…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

The Startup
The Startup

Published in The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +772K followers.

Shawn Shi
Shawn Shi

Written by Shawn Shi

Senior Software Engineer at Microsoft. Ex-Machine Learning Engineer. When I am not building applications, I am playing with my kids or outside rock climbing!

No responses yet