Skip to main content

Posts

Showing posts from July, 2026

Azure AI Search with C#: Build Smart Search (2026)

Learn Azure AI Search with C# — index data, run vector and hybrid queries, and add RAG to your .NET app. Start building intelligent search today. If your application's search box still runs a LIKE '%term%' query against SQL Server, your users are quietly suffering. They type "cheap laptop for uni" and get zero results because your catalogue says "affordable notebook for students." Azure AI Search with C# fixes exactly this problem: it combines classic keyword search, vector embeddings, and semantic reranking into a single managed service that you can drive from .NET with a few dozen lines of code. In this tutorial you'll build a working search index from scratch, run keyword, vector, and hybrid queries, and finish with a Retrieval Augmented Generation (RAG) pattern that grounds an LLM in your own data. This guide targets .NET 9 and the Azure.Search.Documents v11 SDK. Every snippet is runnable. We'll explain why each design choice matter...

C# Interfaces vs Abstract Classes: Complete Guide 2026

Learn C# interfaces vs abstract classes with real code examples. Master when to use each, best practices, and common pitfalls. Start coding smarter today. If you have ever sat in a technical interview or stared at a design decision in Visual Studio, you have hit this question: C# interface vs abstract class — which one should you use? It is one of the most searched C# topics for a reason. Both let you define contracts and share behavior, both power polymorphism, and both look deceptively similar at first glance. But choosing the wrong one leads to rigid, hard-to-maintain code. In this complete guide, we will break down the real difference between interfaces and abstract classes in C#, show runnable code examples, cover modern C# features like default interface methods, and give you a clear decision framework. Whether you are a beginner learning C# OOP concepts or a senior engineer refining your architecture, this article will make the choice obvious. What Is an Interface in ...

Generative AI in .NET: Architecture Patterns for C# Apps

Learn generative AI in .NET with proven enterprise patterns — RAG, Semantic Kernel, streaming, and resilience in C#. Start building smarter apps today. Generative AI in .NET has moved from experiment to expectation. In 2026, enterprise teams across the USA, UK, Canada, Australia, and India are being asked to ship AI copilots, document summarizers, and intelligent search into existing C# applications — and to do it with the same reliability standards as any other production service. The problem? Most tutorials show you how to call an LLM API in ten lines, then leave you alone with the hard parts: architecture, grounding, resilience, cost control, and testing. This guide covers the architecture patterns that actually matter when you integrate generative AI into .NET enterprise apps: the abstraction layer, Retrieval-Augmented Generation (RAG), streaming, tool calling, and the operational guardrails that keep an AI feature from becoming a production incident. Every example is runna...

C# Collections Performance: List vs Dictionary vs HashSet

Master C# collections performance: List vs Dictionary vs HashSet vs Queue with Big-O tables, real benchmarks, and code examples. Pick the right one today. Choosing the right data structure is one of the highest-leverage performance decisions you can make in .NET — and C# collections are where most of those decisions happen. Should you use a List<T> or a Dictionary<TKey, TValue> ? When does a HashSet<T> beat both? And where does Queue<T> fit in? In this guide, we'll compare the four most-used collections in C# with Big-O complexity tables, runnable benchmark code, and clear rules for when to use each. By the end, you'll be able to justify your collection choice in a code review — not just guess. Why C# Collections Performance Matters Every collection type in .NET makes a trade-off. List<T> gives you cheap indexed access and great iteration speed but slow lookups by value. Dictionary<TKey, TValue> gives you near-instant lookups...

How to Dockerize an ASP.NET Core App in .NET 9

Learn how to dockerize an ASP.NET Core app in .NET 9 with a step-by-step Dockerfile tutorial, best practices, and deployment tips. Start containerizing today! If you want to dockerize an ASP.NET Core app , .NET 9 makes it easier than any previous release. Containers have become the default way to ship web applications — every major cloud (Azure, AWS, Google Cloud) runs them natively, and "it works on my machine" bugs largely disappear when your app ships with its entire runtime environment. In this tutorial, you'll learn how to containerize a .NET 9 ASP.NET Core application with a production-ready Dockerfile, understand why each instruction matters, run it locally with Docker Compose, and deploy it to the cloud. We'll also cover the built-in SDK container publishing feature that lets you skip the Dockerfile entirely. Why Dockerize an ASP.NET Core App? Before writing any code, it's worth understanding what containers actually buy you, because the "why...

Prevent XSS in ASP.NET Core: Complete Security Guide

Learn how to prevent cross-site scripting (XSS) in ASP.NET Core with encoding, CSP, and sanitization. Complete guide with C# code examples — read now. Cross-site scripting (XSS) has appeared in every OWASP Top 10 list since the project began, and it remains one of the most commonly reported vulnerabilities in web applications today. If you build web apps with ASP.NET Core, the good news is that the framework gives you strong cross-site scripting prevention out of the box — but only if you understand where those protections apply and, more importantly, where they silently stop applying. This complete guide explains what XSS is, how attackers exploit it, and exactly how to prevent it in ASP.NET Core using output encoding, Content Security Policy, HTML sanitization, and secure cookie configuration. What Is Cross-Site Scripting (XSS)? Cross-site scripting is an injection attack where an attacker gets their own JavaScript to run in another user's browser, in the security con...

Repository and Unit of Work Pattern in C# with EF Core

Last updated: September 29, 2026 · Tested with .NET 10 (SDK 10.0.201) and EF Core 10.0.12 on SQLite Short answer: the Unit of Work pattern groups several changes into one commit so they all succeed or all fail, and the Repository pattern hides how entities are loaded and saved behind an interface. In EF Core you already have both: DbContext is the unit of work, DbSet<T> is the repository, and one SaveChangesAsync() call is one database transaction. Wrap them in your own IUnitOfWork and IRepository<T> only when you get something for it: named queries in one place, a business layer that does not reference EF Core, or simpler unit tests. Below is a working implementation on .NET 10, with the real output for commits, rollbacks and the one mistake that silently breaks atomicity. What the Two Patterns Do A repository behaves like an in-memory collection of domain objects. Instead of writing _context.Customers.Where(c => c.IsActive).ToList() in ten places, you cal...

Azure Service Bus with C#: Complete Tutorial (2026)

Learn Azure Service Bus with C# in this hands-on tutorial. Master queues, topics, and event-driven architecture with runnable .NET code examples. Start now! If you are building distributed systems on Microsoft's cloud, learning Azure Service Bus with C# is one of the highest-value skills you can add to your toolkit. As applications move away from monolithic designs toward microservices and event-driven architecture, a reliable message broker becomes the backbone that keeps services loosely coupled, resilient, and scalable. In this Azure Service Bus tutorial, you'll learn exactly how to send and receive messages using queues and topics with the modern Azure.Messaging.ServiceBus .NET SDK, understand why asynchronous messaging matters, and avoid the pitfalls that trip up most developers. Whether you're a beginner searching "how to use Azure Service Bus," an intermediate developer looking for best practices, or a senior engineer designing advanced event-drive...