Skip to main content
Jagdish Kumawat
Founder @ Dewiride
View all authors

TypedResults vs Results in ASP.NET Core Minimal APIs

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

Results.Ok(x) and TypedResults.Ok(x) put the same response on the wire. The difference is what the rest of your app can see before the request happens. With TypedResults and a declared return type, the OpenAPI document knows every status and body your endpoint can return, without any extra code. Here are both versions of one endpoint, and the documents they produce.

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

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

Add a CancellationToken parameter to a minimal API endpoint, pass it to EF Core, and the work can stop when the client goes away. That's the idea, so I measured what it does on MySQL with Oracle's connector. The token fires, and the next step stops. A statement that's already running keeps going until it ends, so the token isn't a substitute for a command timeout.

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

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

When a unique index refuses a value, EF Core throws an exception, and your API answers 500. But nothing broke: the client asked for something that already exists, and 409 Conflict is the right answer. This guide reads MySQL's error number from the exception, and catches only that error, with a small helper you can reuse.

How to Use a Concurrency Token in EF Core with MySQL

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

When two people edit the same row, the second save overwrites the first, and nobody finds out. A concurrency token fixes this: a column that changes with every update, and that EF Core adds to the WHERE of each UPDATE. If it changed since you read the row, the update finds nothing, and you can tell the client. This guide adds one on MySQL.