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. ...
Implements soft deletes in EF Core three ways on a Book entity: manual IsDeleted flagging, a global HasQueryFilter driven by a shared SoftDeletableModel base class exposing IsDeleted and DeletedAt, and a SaveChanges override, comparing how each approach affects querying and rollback safety. ...
Walks through four practical C# reflection scenarios: invoking a method on a runtime ClassA instance via Activator.CreateInstance and MethodInfo.Invoke, then building a dynamic CSV exporter, an automatic property-to-property model mapper, and a plugin loader, plus tips for efficient use. ...
Explains when GraphQL beats REST in .NET via three cases: a social feed fetching nested author/likes/comments in one query, an e-commerce app returning different fields to mobile versus web, and an IoT dashboard using GraphQL subscriptions over WebSockets, then builds an API with HotChocolate. ...
Compares Newtonsoft.Json, with roughly 6 billion NuGet downloads, JsonProperty attributes, and JsonConvert.SerializeObject, against System.Text.Json's JsonPropertyName attribute and JsonSerializer.Serialize, introduced in .NET Core 3.0, covering nested object graphs to help decide when to migrate. ...