eQuantic.Core.Api.Crud.Client 1.9.1

dotnet add package eQuantic.Core.Api.Crud.Client --version 1.9.1
                    
NuGet\Install-Package eQuantic.Core.Api.Crud.Client -Version 1.9.1
                    
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="eQuantic.Core.Api.Crud.Client" Version="1.9.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="eQuantic.Core.Api.Crud.Client" Version="1.9.1" />
                    
Directory.Packages.props
<PackageReference Include="eQuantic.Core.Api.Crud.Client" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add eQuantic.Core.Api.Crud.Client --version 1.9.1
                    
#r "nuget: eQuantic.Core.Api.Crud.Client, 1.9.1"
                    
#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.
#:package eQuantic.Core.Api.Crud.Client@1.9.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=eQuantic.Core.Api.Crud.Client&version=1.9.1
                    
Install as a Cake Addin
#tool nuget:?package=eQuantic.Core.Api.Crud.Client&version=1.9.1
                    
Install as a Cake Tool

eQuantic.Core.Api.Crud Library

The eQuantic Core API CRUD provides all the implementation needed to publish CRUD APIs.

To install eQuantic.Core.Api.Crud, run the following command in the Package Manager Console

Install-Package eQuantic.Core.Api.Crud

Example of implementation

The data entities

[Table("orders")]
public class OrderData : EntityDataBase
{
    [Key]
    public string Id { get; set; } = string.Empty;
    public DateTime Date { get; set; }
    
    public virtual ICollection<OrderItemData> Items { get; set; } = new HashSet<OrderItemData>();
}

[Table("orderItems")]
public class OrderItemData : EntityDataBase, IWithReferenceId<OrderItemData, int>
{
    [Key]
    public int Id { get; set; }
    public int OrderId { get; set; }
    
    [ForeignKey(nameof(OrderId))]
    public virtual OrderData? Order { get; set; }
    
    [Required]
    [MaxLength(200)]
    public string Name { get; set; } = string.Empty;
}

The models

public class Order
{
    public string Id { get; set; } = string.Empty;
    public DateTime Date { get; set; }
}

public class OrderItem
{
    public int Id { get; set; }
    public int OrderId { get; set; }
    public string Name { get; set; } = string.Empty;
}

The request models

public class OrderRequest
{
    public DateTime? Date { get; set; }
}

public class OrderItemRequest
{
    public string? Name { get; set; }
}

The mappers

public class OrderMapper : IMapper<OrderData, Order>, IMapper<OrderRequest, OrderData>
{
    public Order? Map(OrderData? source)
    {
        return Map(source, new Order());
    }

    public Order? Map(OrderData? source, Order? destination)
    {
        if (source == null)
        {
            return null;
        }

        if (destination == null)
        {
            return Map(source);
        }

        destination.Id = source.Id;
        destination.Date = source.Date;

        return destination;
    }

    public OrderData? Map(OrderRequest? source)
    {
        return Map(source, new OrderData());
    }

    public OrderData? Map(OrderRequest? source, OrderData? destination)
    {
        if (source == null)
        {
            return null;
        }

        if (destination == null)
        {
            return Map(source);
        }
        
        destination.Date = source.Date ?? DateTime.UtcNow;

        return destination;
    }
}

The services

public interface IOrderService : ICrudService<Order, OrderRequest>
{
    
}

[MapCrudEndpoints]
public class OrderService : CrudServiceBase<Order, OrderRequest, OrderData, UserData>, IOrderService
{
    public OrderService(IQueryableUnitOfWork unitOfWork, IMapperFactory mapperFactory) : base(unitOfWork, mapperFactory)
    {
    }
}

The Program.cs

var builder = WebApplication.CreateBuilder(args);
var assembly = typeof(Program).Assembly;

builder.Services.AddDbContext<ExampleDbContext>(opt =>
    opt.UseInMemoryDatabase("ExampleDb"));
        
builder.Services.AddQueryableRepositories<ExampleUnitOfWork>(opt =>
{
    opt.FromAssembly(assembly)
        .AddLifetime(ServiceLifetime.Scoped);
});

builder.Services
    .AddMappers(opt => opt.FromAssembly(assembly))
    .AddTransient<IExampleService, ExampleService>()
    .AddControllers()
    .AddJsonOptions(options =>
    {
        options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
        options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
    })
    .AddFilterModelBinder()
    .AddSortModelBinder();

builder.Services
    .AddEndpointsApiExplorer()
    .AddApiDocumentation(opt => opt.WithTitle("Example API"));

var app = builder.Build();

if (app.Environment.IsDevelopment())
{
    app.UseApiDocumentation();
}

app.UseHttpsRedirection();
app.UseRouting();
app.MapControllers();
app.MapCrud<Order, OrderRequest, IOrderService>();

app.Run();

or

...
app.MapAllCrud(opt => opt.FromAssembly(assembly));
app.Run();
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
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.9.1 134 7/6/2025
1.9.0 144 6/22/2025
1.8.3 141 6/17/2025
1.8.2 288 6/11/2025
1.8.1 286 6/11/2025
1.8.0 90 5/30/2025
1.7.35 148 5/29/2025
1.7.34 73 5/10/2025
1.7.33 77 5/10/2025
1.7.32 109 4/19/2025
1.7.31 99 4/19/2025
1.7.30 118 2/27/2025
1.7.29 126 2/23/2025
1.7.28 121 2/18/2025
1.7.27 115 1/21/2025
1.7.26 115 1/10/2025
1.7.25 102 1/8/2025
1.7.24 110 12/27/2024
1.7.23 118 12/26/2024
1.7.22 102 12/26/2024
1.7.21 115 11/20/2024
1.7.20 104 11/19/2024
1.7.19 118 11/9/2024
1.7.18 127 10/11/2024
1.7.17 124 10/4/2024
1.7.16 113 10/4/2024
1.7.15 121 10/3/2024
1.7.14 134 9/4/2024
1.7.13 119 9/2/2024
1.7.12 140 9/1/2024
1.7.11 188 8/25/2024
1.7.10 150 8/22/2024
1.7.9 100 8/2/2024
1.7.8 109 7/29/2024
1.7.7 111 7/28/2024
1.7.6 112 7/27/2024
1.7.5 113 7/23/2024
1.7.4 119 7/22/2024
1.7.3 131 6/26/2024
1.7.2 131 6/26/2024
1.7.1 144 5/31/2024
1.7.0 143 5/29/2024
1.6.26 132 5/18/2024
1.6.25 143 5/15/2024
1.6.24 125 5/14/2024
1.6.23 159 5/4/2024
1.6.22 140 5/4/2024
1.6.21 157 4/28/2024
1.6.20 142 4/21/2024
1.6.19 144 4/20/2024
1.6.18 141 4/20/2024
1.6.17 126 4/11/2024
1.6.16 126 4/11/2024
1.6.15 142 4/9/2024
1.6.14 142 4/4/2024
1.6.13 133 4/2/2024
1.6.12 145 3/21/2024
1.6.11 140 3/21/2024
1.6.10 156 3/18/2024
1.6.9 153 3/10/2024
1.6.8 161 2/18/2024
1.6.7 150 2/17/2024
1.6.6 161 2/14/2024
1.6.5 152 2/13/2024
1.6.4 152 2/12/2024
1.6.3 146 2/10/2024
1.6.2 139 2/10/2024
1.6.1 163 1/22/2024
1.6.0 191 12/21/2023
1.5.2 152 12/10/2023
1.5.1 157 12/5/2023
1.5.0 149 12/5/2023
1.4.0 137 12/3/2023
1.3.3 157 11/18/2023
1.3.2 121 11/18/2023
1.3.1 176 11/15/2023
1.3.0 91 11/15/2023
1.2.3 112 11/2/2023
1.2.2 104 11/2/2023
1.2.1 181 10/21/2023
1.2.0 110 10/21/2023

Conventions for API CRUD Client Layer