Skip to main content

Blog Archive

Every post on Dewiride Developer Blogs, newest first. Pick a year or a month to narrow it down, or page through them all.

Posts
1,085
Topics
132
Reading time
130 h
First post
Jun 2025

Posts 601–630 of 1,085 · November 4, 2026

Page 21 of 37

November 2026

802 posts

Wednesday, November 4, 2026

30 of 91 posts

  1. What UseAffectedRows Does in a MySQL Connection String for .NET C#

    UseAffectedRows decides whether MySQL reports rows changed or rows found. With Oracle's MySql.Data it's off by default, and turning it on makes EF Core throw DbUpdateConcurrencyException when an UPDATE writes the same values. Measured both ways on .NET 10 and MySQL 9.7.

  2. How to Add Summaries and Tags to an OpenAPI Document in a Minimal API

    Make a generated OpenAPI document readable: WithTags groups endpoints, WithSummary and WithDescription explain them, and ProducesProblem and ProducesValidationProblem list the errors TypedResults can't. Real JSON from a .NET 10 minimal API, shown in Scalar.

  3. How to Log with the LoggerMessage Source Generator in .NET C#

    Replace logger.LogInformation with a [LoggerMessage] partial method: an event ID, a level and a message template in one place, and generated code behind it that the CA1848 rule asks for. Real log output from a .NET 10 minimal API, including a static class's logger.

  4. Why You Should Not Return EF Core Entities from a Web API

    Binding and returning EF Core entities looks like less code, until a client picks its own primary key, a navigation property crashes the JSON, and a renamed column breaks every app. All three shown with real requests against .NET 10 and MySQL, and the small records that prevent them.

  5. How to Set Different Log Levels per Environment in appsettings.json

    See every SQL statement on your machine and none in Production, with one setting in appsettings.json and another in appsettings.Development.json. Real logs from a .NET 10 C# Web API in both environments, how the most specific category wins, and how to change a level for one run.

  6. How to Use TimeProvider Instead of DateTime.UtcNow in .NET C#

    Ask for the time through TimeProvider instead of calling DateTime.UtcNow, so code that depends on the clock can run with any time you choose. Register it in ASP.NET Core, use GetUtcNow, and swap in a fixed clock, with a one-file program you can run.

  7. How to Use Route Constraints in ASP.NET Core Minimal APIs

    What {id:int} does in an ASP.NET Core minimal API, tested with real requests: when a constraint answers 404, when a plain parameter answers 400, and min, guid and regex constraints. Plus why Microsoft says not to use constraints for input validation.

  8. How to Bind Query String Parameters with AsParameters in a Minimal API

    Replace a long list of minimal API parameters with one record. AsParameters fills it from the query string and services, with defaults and validation. Includes the [property:] detail you need on ASP.NET Core 10 to keep the OpenAPI document working.

  9. How to Write a Custom Validation Attribute in .NET C#

    Write your own data annotation in .NET C#: a Money attribute that allows only amounts a decimal(12,2) column can store exactly. Inherit ValidationAttribute, override IsValid, set the message, and use it on a request record. Real 400 responses from a .NET 10 minimal API.

  10. How to Validate Minimal API Requests in .NET 10 C# with AddValidation

    .NET 10 adds built-in validation to minimal APIs. Register AddValidation, put data annotations on your request records, and bad requests get a 400 before your handler runs, including items inside lists. Real responses before and after, on a .NET 10 API with MySQL.

  11. How to Return Problem Details Errors in ASP.NET Core

    Give every error from an ASP.NET Core API the same JSON shape: AddProblemDetails, UseExceptionHandler and UseStatusCodePages, before and after with real responses from .NET 10, plus your own errors with TypedResults.Problem. No stack traces reach the client.

  12. TypedResults vs Results in ASP.NET Core Minimal APIs

    Results and TypedResults send the same HTTP response, but only one tells the OpenAPI document what your endpoint returns. Two versions of the same .NET 10 endpoint, the documents they generate side by side, and the return type that makes TypedResults work.

  13. How to Return 201 Created with a Location Header from a Minimal API

    Answer a successful POST the way HTTP intends: 201 Created, a Location header that points at the new resource, and the resource in the body. Both TypedResults.Created with a path and CreatedAtRoute with a named route, with the real responses from .NET 10.

  14. How to Move Minimal API Endpoints into Their Own Class

    Keep Program.cs short: move ASP.NET Core minimal API endpoints into a static class with an extension method on IEndpointRouteBuilder, one folder per feature, with handlers as private methods. The complete pattern from a real .NET 10 C# API.

  15. How to Group Minimal API Endpoints with MapGroup

    Stop repeating /api/v1/categories on every route. MapGroup gives a set of ASP.NET Core minimal API endpoints a shared prefix, shared settings such as WithTags, and groups inside groups. Built on a real .NET 10 API, with the routes it produces.

  16. How to Cancel EF Core Queries with a CancellationToken in a Minimal API

    Pass the request's CancellationToken to EF Core in a minimal API, and see what it really does on MySQL: with Oracle's connector, the token stopped the next query, but a query already running kept going until it finished. Measured with SLEEP and MySQL's process list.

  17. Why Each Request Gets Its Own DbContext in ASP.NET Core

    AddDbContext registers a scoped service, so each HTTP request gets its own DbContext, and everything in that request shares it. Proved with real ContextId values, then what the rule means for background tasks, singletons and startup code.

  18. How to Return 409 Conflict for a Duplicate Key with EF Core and MySQL

    Turn MySQL's duplicate entry error into a clear 409 Conflict in a .NET C# Web API: a small extension method reads the error number from DbUpdateException, and catch with when handles only that error. The same pattern works for foreign key errors, with real before and after output.

  19. How to Use a Concurrency Token in EF Core with MySQL

    Stop two people silently overwriting each other's changes: add an int Version column, mark it with IsConcurrencyToken, compare the version the client read, and answer 409 on a conflict. Before and after, with the real SQL from EF Core 10 and MySQL 9.7.

  20. How to Sort EF Core Results from a Query String Safely

    Let API clients choose a sort order without letting them touch your SQL: an allow-list with AllowedValues, a switch that maps each value to OrderBy, and ThenBy on the key so pages stay stable. Real requests and SQL from a .NET 10 API on MySQL.

  21. How to Add Optional Filters to an EF Core Query

    Build an EF Core query in pieces, adding a Where only when a filter is given. Because IQueryable doesn't run until the end, each request gets exactly the SQL it needs. Real SQL from MySQL for no filter, one filter and a search.

  22. How to Search Text with EF Core on MySQL: Contains, StartsWith and LIKE

    Compare EF Core's text searches on MySQL with Oracle's provider: Contains becomes LOCATE and ignores case, StartsWith and EndsWith add COLLATE utf8mb4_bin and don't, and EF.Functions.Like follows the column and treats % as a wildcard. Real SQL and results for each.

  23. How to Add Paging to an EF Core Query with Skip and Take

    Page through rows with EF Core's Skip and Take, sorted so rows can't move between pages, with a total count and a page size limit. See the LIMIT and OFFSET it sends to MySQL 9.7, and a paged response record for a .NET C# Web API.

  24. How to Delete Rows Without Loading Them with ExecuteDeleteAsync in EF Core

    Delete one row or many with one DELETE statement, using EF Core's ExecuteDeleteAsync. Read the row count for a clean 404, and handle the difference that catches people: a foreign key failure is a plain MySqlException here, not a DbUpdateException. Real output from MySQL 9.7.

  25. How to Update Rows Without Loading Them with ExecuteUpdateAsync in EF Core

    Change one row or thousands with one UPDATE statement, using EF Core's ExecuteUpdateAsync: set constants, set values based on the current ones, and read the row count. Plus the two traps, stale tracked objects and concurrency tokens, shown with real output from MySQL 9.7.

  26. How to Delete a Row with EF Core and SaveChangesAsync

    Delete a row with EF Core 10: load it, call Remove, then SaveChangesAsync. The real SQL from MySQL, a 204 or 404 answer for a Web API, and a clean 409 when other rows still point at it through a foreign key.

  27. How to Update a Row with EF Core and SaveChangesAsync

    Update a row with EF Core 10: load it, change a property, and call SaveChangesAsync. The real SQL shows only the changed column is written, and no UPDATE at all when nothing changed. Compared with calling Update on a new object, which writes every column.

  28. EF Core Entity States Explained: Detached, Added, Unchanged, Modified and Deleted

    Follow one EF Core entity through every state, from Detached to Added, Unchanged, Modified, Deleted and back to Detached, with the state printed at each step and the SQL each save sends. Real output from EF Core 10 and MySQL 9.7.

  29. How to See What EF Core Will Save with ChangeTracker.DebugView

    ChangeTracker.DebugView shows every entity EF Core is tracking, its state, and which properties changed, before you call SaveChangesAsync. Read its LongView output, line by line, from a real change on EF Core 10 with MySQL.

  30. How to See the SQL of a LINQ Query with ToQueryString in EF Core

    ToQueryString shows the SQL EF Core would send for a LINQ query, without running it. Use it for one query instead of turning on logging for the whole app, and see how constants and parameters appear, on EF Core 10 with MySQL 9.7.