CommonNetFuncs.Web.Api
4.0.40
See the version list below for details.
dotnet add package CommonNetFuncs.Web.Api --version 4.0.40
NuGet\Install-Package CommonNetFuncs.Web.Api -Version 4.0.40
<PackageReference Include="CommonNetFuncs.Web.Api" Version="4.0.40" />
<PackageVersion Include="CommonNetFuncs.Web.Api" Version="4.0.40" />
<PackageReference Include="CommonNetFuncs.Web.Api" />
paket add CommonNetFuncs.Web.Api --version 4.0.40
#r "nuget: CommonNetFuncs.Web.Api, 4.0.40"
#:package CommonNetFuncs.Web.Api@4.0.40
#addin nuget:?package=CommonNetFuncs.Web.Api&version=4.0.40
#tool nuget:?package=CommonNetFuncs.Web.Api&version=4.0.40
CommonNetFuncs.Web.Api
This project contains helper methods for several common functions required by API applications that interact with databases using Entity Framework Core. Works in combination with the BaseDbContextActions class in CommonNetFuncs.EFCore package.
Contents
- CommonNetFuncs.Web.Api
GenericEndpoints
[Description here]
[Class Name] Usage Examples
<details> <summary><h3>Usage Examples</h3></summary>
[MethodNameHere]
[Method Description here]
//Code here
</details>
GenericMinimalEndpoints
Provides static methods for common CRUD and patch operations designed for use in ASP.NET Core minimal API endpoints. Each method accepts an IBaseDbContextActions instance and returns strongly-typed Microsoft.AspNetCore.Http.HttpResults results (Results<Ok<T>, NoContent> or Results<Ok<T>, NoContent, ValidationProblem>), making them directly usable as minimal API route handlers.
GenericMinimalEndpoints Usage Examples
<details> <summary><h3>Usage Examples</h3></summary>
CreateMany
Creates multiple entities and saves them to the database. Returns Ok with the created entities on success, or NoContent on failure.
app.MapPost("/entities", (IEnumerable<MyEntity> models, IBaseDbContextActions<MyEntity, MyDbContext> db) =>
GenericMinimalEndpoints.CreateMany(models, db));
Patch
Applies a JSON Patch document to an existing entity located by primary key. Validates the patched model and returns Ok with the updated entity, ValidationProblem if validation fails, or NoContent if the entity is not found.
app.MapPatch("/entities/{id}", (int id, JsonPatchDocument<MyEntity> patch, IBaseDbContextActions<MyEntity, MyDbContext> db) =>
GenericMinimalEndpoints.Patch<MyEntity, MyDbContext>(id, patch, db));
</details>
GenericMinimalDtoEndpoints
Provides static methods for common CRUD, patch, and update operations for minimal API endpoints that use separate input and output DTO types. Input DTOs are mapped to the entity model before database operations and the result is mapped to the output DTO before returning. Returns Results<Ok<TOutDto>, NoContent> or Results<Ok<TOutDto>, NoContent, ValidationProblem>.
GenericMinimalDtoEndpoints Usage Examples
<details> <summary><h3>Usage Examples</h3></summary>
CreateMany
Creates multiple entities from input DTOs, saves them, and returns the created records mapped to the output DTO type.
app.MapPost("/entities", (IEnumerable<MyInDto> models, IBaseDbContextActions<MyEntity, MyDbContext> db) =>
GenericMinimalDtoEndpoints.CreateMany<MyEntity, MyDbContext, MyInDto, MyOutDto>(models, db));
Update
Retrieves an existing entity by primary key, overwrites its properties from the input DTO, validates the result, and saves. Returns Ok with the updated record mapped to the output DTO, ValidationProblem if validation fails, or NoContent if the entity is not found.
app.MapPut("/entities/{id}", (int id, MyInDto dto, IBaseDbContextActions<MyEntity, MyDbContext> db) =>
GenericMinimalDtoEndpoints.Update<MyEntity, MyDbContext, MyInDto, MyOutDto>(id, dto, db));
</details>
MsgPack
A set of focused components for adding MessagePack support to ASP.NET Core minimal API applications. Unlike a single monolithic middleware, the functionality is split into a request middleware and an endpoint output filter so each can be applied independently.
MsgPackRequestMiddleware
Converts a MessagePack-encoded request body to JSON before the endpoint handler runs, allowing standard [FromBody] parameter binding to work unchanged. Register it in the pipeline before routing.
<details> <summary><h3>Usage Examples</h3></summary>
UseMsgPackRequestBody
Registers MsgPackRequestMiddleware globally so every endpoint accepts MessagePack request bodies.
// Program.cs
app.UseMsgPackRequestBody();
app.MapPost("/entities", (MyEntity entity) => Results.Ok(entity));
</details>
MsgPackOutputFilter
An endpoint filter that intercepts the handler's return value before System.Text.Json serializes it. When the client's Accept header includes application/x-msgpack, the value is serialized directly to MessagePack with no JSON intermediate. Results that carry no body (204, 404 without body, redirects) and problem-detail results (application/problem+json) are passed through unchanged.
<details> <summary><h3>Usage Examples</h3></summary>
WithMsgPackOutput
Attaches MsgPackOutputFilter to an endpoint or route group. Optionally accepts custom MessagePackSerializerOptions; defaults to MessagePackSerializer.DefaultOptions when null.
// Apply to a single endpoint
app.MapGet("/entities/{id}", (int id, IBaseDbContextActions<MyEntity, MyDbContext> db) =>
GenericMinimalEndpoints.GetById(id, db))
.WithMsgPackOutput();
// Apply to an entire route group
RouteGroupBuilder group = app.MapGroup("/entities").WithMsgPackOutput();
group.MapGet("/{id}", (int id) => Results.Ok(myEntity));
</details>
Installation
Install via NuGet:
dotnet add package CommonNetFuncs.Web.Api
License
This project is licensed under the MIT License - see the LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- CommonNetFuncs.Core (>= 4.0.40)
- CommonNetFuncs.DeepClone (>= 4.0.40)
- CommonNetFuncs.EFCore (>= 4.0.40)
- CommonNetFuncs.FastMap (>= 4.0.40)
- MessagePack (>= 3.1.4)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 10.0.7)
- Microsoft.AspNetCore.OpenApi (>= 10.0.7)
- Microsoft.EntityFrameworkCore (>= 10.0.7)
- Scalar.AspNetCore (>= 2.14.11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.1.8 | 0 | 7/7/2026 |
| 4.1.7 | 119 | 6/23/2026 |
| 4.1.6 | 105 | 6/15/2026 |
| 4.1.4 | 110 | 6/10/2026 |
| 4.1.3 | 116 | 6/9/2026 |
| 4.1.2 | 123 | 6/6/2026 |
| 4.1.1 | 108 | 6/5/2026 |
| 4.1.0 | 116 | 6/5/2026 |
| 4.0.56 | 126 | 6/2/2026 |
| 4.0.53 | 126 | 5/28/2026 |
| 4.0.52 | 108 | 5/27/2026 |
| 4.0.48 | 116 | 5/19/2026 |
| 4.0.43 | 151 | 5/14/2026 |
| 4.0.40 | 115 | 5/10/2026 |
| 4.0.39 | 108 | 5/10/2026 |
| 4.0.37 | 107 | 5/9/2026 |
| 4.0.36 | 106 | 5/8/2026 |
| 4.0.34 | 119 | 4/28/2026 |
| 4.0.33 | 125 | 4/23/2026 |