Open Source .NET Library

CRUD APIs in
one line of code

Five endpoints, pagination, filtering, sorting, soft delete, and DTO mapping — from a single method call.


      

Everything built in

1

Pagination, filtering & sorting

Query strings for page, pageSize, filter, and sort work out of the box. No extra code needed.

2

DTO mapping

Separate request/response types with the built-in ReflectionMapper, [MapFrom] attributes, or source-generated Mapperly integration.

3

Soft delete

Implement ISoftDeletable and DELETE sets a flag. Query ?includeDeleted=true to see everything.

4

Response shaping

Envelope wrapping, pagination metadata, and configurable response formats — globally or per entity.

Before and after

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; }
}

Get started

Install the core package and a storage backend.

dotnet add package MapCrud
dotnet add package MapCrud.InMemory  # or MapCrud.EntityFrameworkCore