.NET 6 Blazor introduces “, allowing you to render a component whose type is selected at runtime. No more massive switch statements in render trees. Usage Use Cases Plugin systems where component types are registered dynamically. Dashboard builders with user-selectable widgets. Key Takeaways Combine with `System.Reflection` to load components by name. Parameters must be passed […]
Read more →Tag: .NET
Top 5 Features of Entity Framework Core 6
EF Core 6 ships with .NET 6 and brings several performance and usability improvements. Here are the highlights. 1. Compiled Models Pre-compile your model to avoid expensive startup reflection. 2. Temporal Tables (SQL Server) 3. Pre-Convention Model Configuration Apply conventions like “all strings max 256” globally. 4. Migration Bundles Package migrations as executables for CI/CD. […]
Read more →C# 10: Validating Arguments with CallerArgumentExpression
Writing guard clauses like `ArgumentNullException.ThrowIfNull(value)` is great, but error messages often lack context. CallerArgumentExpression captures the expression text at compile time. Example Key Takeaways Zero runtime overhead—it’s a compile-time feature. Use in custom assertion libraries or fluent validation.
Read more →C# 10: Constant Interpolated Strings
Prior to C# 10, you couldn’t use string interpolation (`$”…”`) in `const` declarations. Now you can, as long as all parts are also constants. Example Use Case Useful for defining attribute strings cleanly. Key Takeaways Components must be `const`; no runtime expressions allowed. Good for reducing magic strings.
Read more →Testing .NET 6 Applications: Integration Testing with WebApplicationFactory
Unit tests are not enough. Integration tests verify your app works end-to-end, including middleware, dependency injection, and database logic. `WebApplicationFactory` spins up an in-memory test host. Setup Customizing Services Replace the real database with an in-memory one. Key Takeaways Use **Testcontainers** (covered earlier) for real SQL testing. Check HTTP status codes, response bodies, and headers.
Read more →.NET 6: Minimal APIs Explained
Minimal APIs are the biggest shift in ASP.NET Core since version 1.0. They remove the MVC ceremony (Controllers, Actions, Filters) in favor of a fluent lambda-based syntax. The Code Is it just for tiny apps? No. Performance is technically better than MVC (fewer allocations, no Filter Pipeline overhead). However, organization becomes the challenge. You don’t […]
Read more →