eQuantic.Core.Application 1.6.17

dotnet add package eQuantic.Core.Application --version 1.6.17
NuGet\Install-Package eQuantic.Core.Application -Version 1.6.17
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.Application" Version="1.6.17" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add eQuantic.Core.Application --version 1.6.17
#r "nuget: eQuantic.Core.Application, 1.6.17"
#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 eQuantic.Core.Application as a Cake Addin
#addin nuget:?package=eQuantic.Core.Application&version=1.6.17

// Install eQuantic.Core.Application as a Cake Tool
#tool nuget:?package=eQuantic.Core.Application&version=1.6.17

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 net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 is compatible.  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 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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on eQuantic.Core.Application:

Package Downloads
eQuantic.Core.Application.Crud

eQuantic Application CRUD Library

eQuantic.Core.Api

eQuantic API Library

eQuantic.Core.Persistence

eQuantic Persistence Library

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.6.17 309 4/11/2024
1.6.16 115 4/11/2024
1.6.15 124 4/9/2024
1.6.14 146 4/4/2024
1.6.13 181 4/2/2024
1.6.12 194 3/21/2024
1.6.11 138 3/21/2024
1.6.10 197 3/18/2024
1.6.9 157 3/10/2024
1.6.8 153 2/18/2024
1.6.7 124 2/17/2024
1.6.6 147 2/14/2024
1.6.5 136 2/13/2024
1.6.4 157 2/12/2024
1.6.3 152 2/10/2024
1.6.2 139 2/10/2024
1.6.1 149 1/22/2024
1.6.0 316 12/21/2023
1.5.2 195 12/10/2023
1.5.1 163 12/5/2023
1.5.0 157 12/5/2023
1.4.0 162 12/3/2023
1.3.3 198 11/18/2023
1.3.2 146 11/18/2023
1.3.1 188 11/15/2023
1.3.0 140 11/15/2023
1.2.3 169 11/2/2023
1.2.2 128 11/2/2023
1.2.1 215 10/21/2023
1.2.0 120 10/21/2023
1.1.6 164 10/9/2023
1.1.5 170 10/7/2023
1.1.4 182 10/2/2023
1.1.3 149 10/1/2023
1.1.2 187 9/25/2023
1.1.1 138 9/24/2023
1.1.0 192 9/4/2023
1.0.14 307 8/13/2023
1.0.13 199 8/13/2023
1.0.12 175 8/13/2023
1.0.11 174 8/13/2023
1.0.10 183 8/8/2023
1.0.9 215 8/3/2023
1.0.8 191 7/30/2023
1.0.7 195 7/22/2023
1.0.6 191 7/21/2023
1.0.5 185 7/21/2023
1.0.4 186 7/20/2023
1.0.3 185 7/20/2023
1.0.2 179 7/19/2023
1.0.0.1 181 7/5/2023
1.0.0 182 7/5/2023

Conventions for Application Layer