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. ...
Traces what EF Core's ChangeTracker does with a Student/Enrollment model: context.Add marks new entities Added and assigns temporary keys, SaveChanges emits INSERTs in dependency order and backfills the real StudentId foreign key, versus attaching an Enrollment to an already-tracked Student. ...
Goes beyond Singleton/Scoped/Transient basics with concrete .NET DI patterns: resolving services manually in an MqttListener via IServiceProvider versus IServiceScopeFactory for scoped lifetimes, injecting IEnumerable to get every registered implementation, and registering variants via AddKeyed. ...