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. ...
Speeds up EF Core queries on a Building/Floor model: projecting only needed columns into a DTO, disabling tracking per-query with AsNoTracking or globally via HasQueryTrackingBehavior, choosing lazy loading with Microsoft.EntityFrameworkCore.Proxies versus eager loading, plus indexing/pagination. ...
Shows C# tuple syntax from Tuple<T> through named literal tuples (C# 7.0+), nested tuples, and deconstruction, then two real examples: passing a (Latitude, Longitude) tuple as a method parameter, and returning a (Subject, Body) tuple from an email-content generator keyed off an EmailTypeEnum. ...
Builds C# delegate intuition with a waiter/chef analogy, then two code examples: a multicast PrintMessage delegate chaining PrintToConsole and PrintToFile via +=, and a menu-driven console app mapping user choices to AddContact/ViewContact/DeleteContact through a Dictionary<string, PrintMessage>. ...