MinimalApiCrud 1.3.0

dotnet add package MinimalApiCrud --version 1.3.0                
NuGet\Install-Package MinimalApiCrud -Version 1.3.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MinimalApiCrud" Version="1.3.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MinimalApiCrud --version 1.3.0                
#r "nuget: MinimalApiCrud, 1.3.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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

Nuget

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.3.0 109 9/23/2024
1.2.1 450 10/20/2022
1.2.0 403 10/20/2022
1.1.1 408 10/19/2022
1.1.0 397 10/3/2022
1.0.2 386 10/2/2022
1.0.1 402 9/28/2022
1.0.0 393 9/27/2022