Open Source .NET Library
Five endpoints, pagination, filtering, sorting, soft delete, and DTO mapping — from a single method call.
Query strings for page, pageSize, filter, and sort work out of the box. No extra code needed.
Separate request/response types with the built-in ReflectionMapper, [MapFrom] attributes, or source-generated Mapperly integration.
Implement ISoftDeletable and DELETE sets a flag. Query ?includeDeleted=true to see everything.
Envelope wrapping, pagination metadata, and configurable response formats — globally or per entity.
Replace hundreds of lines of boilerplate with a single call.
Without MapCrud ~40 lines per entity
// Define 5 endpoints manually... app.MapGet("/products", async (AppDbContext db) => await db.Products.ToListAsync()); app.MapGet("/products/{id}", async (Guid id, AppDbContext db) => await db.Products.FindAsync(id) is Product p ? Results.Ok(p) : Results.NotFound()); app.MapPost("/products", async (Product p, AppDbContext db) => { db.Products.Add(p); await db.SaveChangesAsync(); return Results.Created($"/products/{p.Id}", p); }); app.MapPut("/products/{id}", async (...) => { // update logic... }); app.MapDelete("/products/{id}", async (...) => { // delete logic... }); // + pagination, filtering, sorting, // validation, DTO mapping... // repeat for every entity
With MapCrud 1 line
// All five endpoints in one line app.MapCrud<Product>("products"); // Need DTOs? app.MapCrud<Product>("products", o => o .WithRequest<CreateProductDto>() .WithResponse<ProductDto>() .DisableDelete()); // Global config builder.Services.AddMapCrud<AppDbContext>(o => o .UseEnvelope() .UsePagination(defaultPageSize: 10)); // Soft delete — just implement the interface public class Article : ISoftDeletable { public Guid Id { get; set; } public bool IsDeleted { get; set; } public DateTime? DeletedAt { get; set; } }
Install the core package and a storage backend.
dotnet add package MapCrud
dotnet add package MapCrud.InMemory # or MapCrud.EntityFrameworkCore