When building enterprise applications in C#, a common architectural trap is writing procedural code disguised as object-oriented code. This usually happens when we rely entirely on anemic data bags public get; set; DTOs for business logic, forcing ou...
For years, C# interfaces were limited strictly to instance members.
If you wanted to define a contract requiring a class or struct to implement a static method like a string parser or a factory method you had to rely on reflection, runtime type che...
Moving from backend C# and enterprise patterns into native mobile development can feel like stepping into a whole new world. But after building my very first mobile app using Kotlin, the experience was a revelation—the syntax felt natural, the deve...
ChatGPT, Claude, Gemini, or Cursor? Which AI Tool Is Your Go-To and Why?
Hey CodeLegion community! 💻
Whether you are debugging complex codebases, writing technical documentation, exploring new frameworks, or just trying to automate daily workflows...
Stop Hardcoding Business Rules: Building a Dynamic Workflow Engine in C Sharp
Every growing C# application eventually hits a wall: business logic becomes a tangle of deeply nested if/else checks scattered across service layers. Every time marketing...
Getting Started with GraphQL in ASP.NET and EF Core
GraphQL is a modern API technology that allows clients to request exactly the data they need. Unlike traditional REST APIs, GraphQL uses a single endpoint and gives consumers more control over the ...
You built a nice domain model with rules and private properties — but EF Core wants simple classes with public get; set;.
Don't worry. This guide shows you how to save DDD models to the database without messing up your code. Short sentences. Real ex...
The Two Sum problem sounds complicated, but it's actually very simple.
Imagine you have a list of numbers:
int numbers = { 2, 7, 11, 15 };
And someone asks you:
"Can you find two numbers that add up to 9?"
Looking at the list, you can see that:
...
When developers first start using Entity Framework Core, it's easy to write queries that work—but not all queries perform well.
The good news? A few simple practices can make your queries much faster, use less memory, and generate better SQL.
We'll...
Introduction
The Prototype Design Pattern is a creational design pattern that allows new objects to be created by copying an existing object called a prototype instead of creating them from scratch.
This pattern is particularly useful when:
Obje...
Exploring a Practical Billing API Built with Modern .NET Patterns
The Billing repository https://github.com/stevsharp/Billing is a practical example of how several common .NET architectural patterns can be combined within a billing-focused applicat...
Entity Framework Core EF Core is often introduced as an ORM that simplifies data access, but its real value in enterprise applications comes from features that improve reliability, scalability, and maintainability.
As applications grow and operate ...
This tutorial explains how to build a multithreaded, priority-based job processing system using:
PriorityQueue
SemaphoreSlim
Producer / Consumer pattern
Retry mechanism
Dead Letter Queue DLQ
Multiple workers
1. What is PriorityQueue in C#?
...
Blazor Latest Features
Blazor, Microsoft’s modern web UI framework, has evolved significantly in recent releases .NET 8 and .NET 9. It now provides a powerful mix of full-stack capabilities, flexible rendering, and high performance, making it a st...
Understanding the Producer-Consumer Pattern in C Sharp
The Producer-Consumer pattern is one of the most common patterns in concurrent programming.
In simple English, it means this:
One part of the program creates work.
Another part of the program...
The Rule Pattern in C#, and Why It Works So Well with the Result Pattern
Business rules rarely stay in one place.
A small validation starts in a command handler. Another check appears in a service. A third gets added somewhere in the domain. A few...
Building a Blazor Form with the Command Pattern and Undo
In a typical Blazor form, inputs update the model directly. That is simple and works fine for basic CRUD screens, but it starts to feel limiting when you want more control over how changes hap...
Recently, I had a simple coding task. I needed to split an item's quantity across multiple lines.
For example, I had Item 1 with a total quantity of 10, but that quantity could not remain on a single line. It had to be distributed across several lin...
If you ever had to “fix a batch” of invoices, reset workflow statuses, or reprocess failed documents, you know the pain, one mistake and you either update too much, or you update the right rows but lose the evidence of what changed.
SQL Server has a...
When IDbContextFactory enters the chat, and what it actually fixes
Most EF Core examples use a scoped DbContext. In a normal Web API request, that’s fine, the request ends, the context is disposed.
Then you build Blazor Server.
A Blazor Server ci...