MinimalApiCrud 1.3.0
dotnet add package MinimalApiCrud --version 1.3.0
NuGet\Install-Package MinimalApiCrud -Version 1.3.0
<PackageReference Include="MinimalApiCrud" Version="1.3.0" />
paket add MinimalApiCrud --version 1.3.0
#r "nuget: MinimalApiCrud, 1.3.0"
// Install MinimalApiCrud as a Cake Addin #addin nuget:?package=MinimalApiCrud&version=1.3.0 // Install MinimalApiCrud as a Cake Tool #tool nuget:?package=MinimalApiCrud&version=1.3.0
MinimalApiCrud
Nuget package
You can use MinimalApiCrud installing the Nuget package from here https://www.nuget.org/packages/MinimalApiCrud
What is it?
It's a very simple library that permit to create CRUD endpoints for your entities.
It works with .NET Minimal API and .NET 6 and the implementation is covered by unit tests at 100%
Keep in mind that this library try to offer a base set of CRUD endpoints. If you need to customize something you have to write your endpoint.
Important change log
1.2.1 → 1.3.0 Library upgrade
1.2.0 → 1.2.1
Now "Filter" method had pagination!
1.1.1 → 1.2.0
Methods "GetAll" and "Filter" now will return an object with the total count and the items instead of only the items.
Methods
- MapCrud: initialize the library with the data model, the id data type and the data context.
- SetupMapping: configure the mapping between data model and view model. (for details see https://github.com/MapsterMapper/Mapster)
- GetAll: setup the Read endpoint. It's paginated.
- GetOneById: setup the single Read by id endpoint.
- Filter: setup the filters and the comparing logics to retrieve the results. (for details see https://dynamic-linq.net/advanced-parse-lambda#dynamic-lambda))
- Insert: setup the Create endpoint.
- Update: setup the Update endpoint.
- Delete: setup the Delete enpoint.
Example
In this example you can see how configurate endpoints and setup mappings.
For more details, please check the example here https://github.com/matteoventuri7/MinimalApiCrud/tree/master/MinimalApi
Program.cs
using var minimalApiCrudBuilder =
app.MapCrud<WeatherForecast, int, WeatherForecastContext>()
.SetupMapping<WeatherForecast, WeatherForecastViewModel>(x =>
x.Map(dest => dest.DisplayDate, src => src.Date.ToLongDateString())
.Map(dest => dest.Temperature, src => src.TemperatureC + "°C"))
.GetAll<WeatherForecastViewModel>(config: x => x.WithName("GetWeatherForecast"))
.GetOneById<WeatherForecastViewModel>()
.Filter<WeatherForecastViewModel>(new Dictionary<string, string> {
{nameof(WeatherForecast.TemperatureC),$"{nameof(WeatherForecast.TemperatureC)} == @0" },
{nameof(WeatherForecast.Summary), $"{nameof(WeatherForecast.Summary)} == @0" } }
, FilterLogic.OR)
.Insert<WeatherForecastDto>()
.Update<WeatherForecastViewModel>()
.Delete("/weatherforecast/{id:int}");
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Mapster (>= 7.4.0)
- System.Linq.Dynamic.Core (>= 1.4.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.