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.

27 posts
Storing JSON data in relational databases using EF Core

JavaScript Object Notation (JSON) is a great fit when you are working with logs, configuration settings, or other flexible data structures. JSON represents data in a human-readable format that many modern applications can parse easily. In this article, you will learn how to store and manage JSON data in relational ...

Soft deletes in EF Core: How to implement and query efficiently

What does your application actually do with a record when a user deletes it? Can your application afford to delete a record permanently? One mistake can result in irreparable damage to the application. Today, I will shed light on D of the CRUD. Among all the CRUD operations, Delete is ...

4 real-life examples of using reflection in C#

As C# developers, we sometimes must interact dynamically with objects, fields, properties, methods, or types. Use cases such as inter-mapping between types, traversing model properties, developing an extensible system, injecting dependencies, etc., demand runtime handling. You may wonder how to tackle such scenarios. In this post, I will show you ...

Understanding GraphQL in .NET: When and why to use it

APIs are the heart of most modern applications. Due to their simplicity and lightweight design, RESTful APIs are a popular choice for client-server communication in most applications. However, APIs can become limiting when fetching complex or related data. The front end may over-fetch or under-fetch the meaningful data. For example, ...

Optimizing JSON Serialization in .NET: Newtonsoft.Json vs. System.Text.Json

JavaScript Object Notation (JSON) is a popular data storage and transmitting format. Whether you are a front-end or back-end developer, you must be familiar with it. As a.NET developer, you don't need an introduction to this text-based data format. The two most prominent libraries are Newtonsoft.Json ...

Understanding EF Core Change Tracking: How It Works Under the Hood

Entity Framework Core (EF Core) makes data handling easy. We all are leveraging its conciseness, flexibility, and rich features in our projects. However, have you ever wondered what goes under the hood? How has EF Core detached us from SQL queries? Today, I will disclose the curtain behind EF Core ...

.NET Dependency Injection: Advanced Techniques Beyond the Basics

Dependency injection (DI) is a powerful feature in .NET applications. It allows you the decoupling of dependencies by injecting required services at runtime, ensuring the modularity and testability of your code. You can create separate services or import them from NuGet packages by registering them into your application. However, injecting ...

Handling Complex Query Scenarios with Entity Framework Core

The database is an integral part of every application. However, it contributes most to the performance of any application due to its presence in almost every operation. In the .NET world, Entity Framework Core (EFCore) is one of the developer's favorite Object-Relational Mapping (ORM). It has simple syntax, ...

Leveraging Tuples in C#: Real-World Use Cases

Well, using OOP in development is a blessing. We define classes to leverage inheritance and abstraction. We easily represent one object as a model. However, using and maintaining these classes can sometimes be tedious for the developers and the application’s memory. You might need to define separate classes or ...