Skip to content

Instantly share code, notes, and snippets.

@jpd21122012
Created June 26, 2025 22:41
Show Gist options
  • Save jpd21122012/3bf172e619e146cea96bc093e5c43905 to your computer and use it in GitHub Desktop.
Save jpd21122012/3bf172e619e146cea96bc093e5c43905 to your computer and use it in GitHub Desktop.
group.MapGet("/", async ([FromServices] DbContext db) =>
await db.Set<Entity>().ToListAsync());
group.MapPost("/", async ([FromBody] Entity item, [FromServices] DbContext db) =>
{
db.Set<Entity>().Add(item);
await db.SaveChangesAsync();
return Results.Created($"/api/entity/{item.Id}", item);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment