Benchmarks JSON serialization of Blog and Course models three ways in C# using BenchmarkDotNet: a reflection-based serializer, a Roslyn source generator, and the .NET 6 incremental source generator, showing how caching compilation results cuts the overhead of repeated code generation. ...
Applies 16 measured optimizations to a single ASP.NET Core PostsController endpoint over a 10,000-row PostgreSQL table, benchmarking each step from EF Core's AsNoTracking (up to 30% faster) through field projection and Skip/Take pagination to reach a cumulative 70% cut in response time. ...
Builds audit logging into a PostgreSQL-backed ASP.NET Core job-portal API using an IAuditableEntity interface with CreatedAtUtc, UpdatedAtUtc, CreatedBy, and UpdatedBy on Applicant and Company entities, noting EF Core's shadow properties as an alternative that avoids adding those fields directly. ...
Builds a Roslyn-based C# source generator from scratch, implementing ISourceGenerator's Initialize and Execute methods in a netstandard2.0 class library so a HelloSayenGenerator injects a working Console.WriteLine method into the compilation at build time with zero runtime cost. ...
Builds an ASP.NET Core AuthorService using Vladimir Khorikov's CSharpFunctionalExtensions library to return Result<T> instead of throwing exceptions for validation failures like a missing name or duplicate email, then contrasts it with OneOf<T> discriminated unions for several possible outcomes. ...
Walks through concrete C# examples of records with value equality like a Coordinate type, the null-coalescing operator, tuple deconstruction for methods such as GenerateEmailContent, global usings that centralize imports across large projects, and C# 12's collection expressions to cut boilerplate. ...
Covers 16 recurring C#/.NET mistakes with code fixes, including catch blocks resetting the stack trace with throw e instead of a bare throw, organizing code by technical layer instead of feature/domain, over-engineering with unneeded abstraction layers, and skipping async/await on DbContext queries. ...
Benchmarks IEnumerable against IAsyncEnumerable in .NET using an EF Core InMemory database seeded with 100,000 and 1,000,000 Book records, measuring memory allocation and execution time to show why IAsyncEnumerable, introduced in .NET Core 3.0 and C# 8.0, cuts overhead for latency-prone sources. ...
Shows how to persist JSON in EF Core across three databases: PostgreSQL's native jsonb column via the Npgsql.EntityFrameworkCore.PostgreSQL package, SQL Server's nvarchar(max) with a HasConversion-based System.Text.Json serializer, and MySQL, all demonstrated on a shared LogEntry/LogDetail model. ...