-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Closed
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-minimal-actionsController-like actions for endpoint routingController-like actions for endpoint routing
Milestone
Description
IResult
-returning static methods would allow something like using static Microsoft.AspNetCore.Http.Results
and makes for better return type inference for IResult-returning lambdas, so you don't have to do casting like the following you have to do using constructors today.
app.MapGet("/todos/{id}", async (int id) =>
{
using var db = new TodoDbContext(options);
if (await db.Todos.FindAsync(id) is not Todo todo)
{
return (IResult)new NotFoundResult();
}
return new JsonResult(todo);
})
With, IResult
returning NotFound
and Ok
methods the (IResult)
casting can be removed.
app.MapGet("/todos/{id}", async (int id) =>
{
using var db = new TodoDbContext(options);
if (await db.Todos.FindAsync(id) is not Todo todo)
{
return NotFound();
}
return Json(todo);
})
martincostello
Metadata
Metadata
Assignees
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-minimal-actionsController-like actions for endpoint routingController-like actions for endpoint routing