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.

67 posts
3 Essential Techniques for Managing Transactions in EF Core

Compares three EF Core transaction techniques on a Building entity: automatic transactions where each SaveChangesAsync call is its own implicit transaction, manual transactions wrapping multiple SaveChangesAsync calls via Database.BeginTransaction, and a strategy using CommitAsync for retries. ...

Caching Strategies in ASP.NET Core

Walks through implementing in-memory caching in ASP.NET Core with the Microsoft.Extensions.Caching.Memory package, covering IMemoryCache injection, absolute and sliding expiration settings, and a CustomerRepository example tested with a debugger. ...

How to implement customized role permissions in ASP.NET Core

Builds custom role permissions into an inventory management ASP.NET Core API: wiring up JWT bearer auth with Swagger, then modeling hierarchical permissions like UserCreate and MaterialStockUpdate via EF Core migrations. ...

Custom model validation attributes in ASP.NET Core

Builds a CustomerDateOfBirthValidation attribute by inheriting ValidationAttribute and overriding IsValid, enforcing an 18-year minimum age with DateTime.TryParse checks - a step-by-step alternative to built-in attributes like Required and StringLength. ...