Ali Hamza Ansari

Ali Hamza Ansari

Meet Ali, a talented .NET developer from Pakistan. Besides blogging, Ali works for a range of international customers doing everything from C# to Azure.

64 posts
EF Core at scale: 5 ways to retrieve large datasets efficiently

EF Core (Entity Framework Core) is a fast ORM. However, once dataset entries increase by another 0, things start to break down. Fetching and filtering of data adds to processing time. Looking at this pitfall, I came up with a few EF Core methods that are specifically designed to work ...

Designing high-throughput APIs for 1M requests/minute .NET

table of contents Scaling horizontally is great… until the bill comes. Hence, as a startup or a big firm, you always need to be careful about billing while maintaining competitiveness. Every user who lands on your application needs high throughput. In today's post, I will share ways to ...

How to upload files in an ASP.NET Core Web API

Files are an integrated part of an application. From a social app to an ERP, some form of media exists in the ecosystem. .NET Core APIs provide built-in support for uploading and fetching documents. In today's post, I will show you how to cleanly and efficiently use ...

The complete guide to mastering Dapper micro-ORM in .NET

For developers who want to taste ORM but don't want to leave SQL either, Dapper is a perfect choice. Dapper runs SQL queries like ADO.NET but returns results as C# objects, like Entity Framework Core. Apart from its abstracting nature, you leverage high-speed data access. The ...

Pattern matching in C#: Advanced scenarios you didn't know

table of contents Pattern matching is not just condition checking. It reflects how you think as a developer. Matching and validation can be achieved in a naive, descriptive way. However, a cleaner approach stands out in terms of readability and sometimes performance. Pattern matching combines patterns to express complex logic ...

12 practices for optimizing PostgreSQL queries for large datasets

A database is the root of most applications. Anything displayed or any operations performed often rely on the database. So, to build a loyal client base, you have to think in terms of a database. In today's post, I will go through some key strategies you can apply ...

EF Core query translation: Why does some LINQ never become SQL?

We know that every Entity Framework Core (EF Core) LINQ query has a corresponding SQL query. That equivalent SQL is actually executed under the hood. Some LINQ expressions involve. NET-specific code, such as calling a method, using a reflection filter, or accessing files. You may have found several code ...

Mapping database views in EF Core without breaking migrations

Entity Framework Core (EF Core) is working fine in your project. But the moment you use views, the migration gets messy. As a developer, I know any problem in the migration is haunting. You have to update and take care of other migrations so they don't get disturbed. ...

How .NET handles exceptions internally (and why they're expensive)

What really happens when you write throw new Exception() in .NET? Microsoft guidelines state that When a member throws an exception, its performance can be orders of magnitude slower.  It's not just a simple jump to a catch block, but a lot goes in CLR (Common Language Runtime) ...