WebApiXGen 1.2.0
See the version list below for details.
dotnet add package WebApiXGen --version 1.2.0
NuGet\Install-Package WebApiXGen -Version 1.2.0
<PackageReference Include="WebApiXGen" Version="1.2.0" />
paket add WebApiXGen --version 1.2.0
#r "nuget: WebApiXGen, 1.2.0"
// Install WebApiXGen as a Cake Addin
#addin nuget:?package=WebApiXGen&version=1.2.0
// Install WebApiXGen as a Cake Tool
#tool nuget:?package=WebApiXGen&version=1.2.0
Provides Generic Web Api Controllers to perform CRUD operations against a Sql Server, including Temporal Tables (GenericDtoController), with DTO support (GenericDtoController), Authorized controller (GenericAuthDtoController)
Product | Versions 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 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. |
.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. |
-
.NETStandard 2.1
- AutoMapper (>= 10.1.1)
- Microsoft.AspNetCore.Authentication.Cookies (>= 2.2.0)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.AspNetCore.Mvc (>= 2.2.0)
- Microsoft.EntityFrameworkCore (>= 5.0.5)
- Microsoft.EntityFrameworkCore.SqlServer (>= 5.0.5)
- System.Data.SqlClient (>= 4.8.2)
- System.Linq.Dynamic.Core (>= 1.2.9)
- System.Text.Json (>= 5.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
// FEATURES:
This package provides CRUD capabilities (and temporal support) for generic controllers based on specific entity types.
Controllers provides those methods/calls
- GET => items list
- GET/key => item by key (in case of multiple keys v: POST GetItemFromBody)
- GET GetItemsByIdList => item list (ActionName:GetItemsByIdList) [FromQuery(Name = "ids")] IEnumerable<TKey> ids
- PUT [FormBody(item)] => updates item from body
- POST [FormBody(item)] => creates item from body
- POST PostItems => creates items (ActionName:PostItems) [FromBody] IEnumerable<T> items
- DELETE/key => deletes item by key (in case of multiple keys v: POST DeleteItemFromBody)
*** Magic Method ***
- POST DoQuery => item list from Dynamic.Linq (ActionName:DoQuery) [FromBody] QryObj (es: QryObj.Qry = "Desc=@0", QryObj.Pars = "pluto")
NB: add package (for 'DoQuery' calls):
Install-Package System.Linq.Dynamic.Core -Version 1.1.0
// USAGE:
// Injections (in startup.cs)
services.AddDbContext<MyContext>(options => options.UseSqlServer(cnx));
services.AddScoped<DbContext, MyContext>();
services.AddScoped(typeof(IGenericLogic<,>), typeof(GenericLogic<,>));
// Simple Controller: manages entities of type MyEntity with a long PK column
public class MyController : GenericController<MyEntity, long>
{
public MyController(IGenericLogic<MyEntity, long> logic) : base(logic) { }
}
// DTO Controller: manages entities of type MyEntityDto (based on MyEntity type) with multiple PK's
public class MyDtoController : GenericDtoController<MyEntityDto, MyEntity, object[]>
{
public MyDtoController(IGenericLogic<MyEntity, object[]> logic, IMapper mapper) : base(logic, mapper) { }
}
// Logic Override (to provide custom implementation of the methods, use ObjectBrowser to inspect them)
public class MyLogic : GenericLogic<MyEntity, string>
{
public MyLogic(MyContext context) :base(context) { }
public async override......
}
TEMPORAL TABLE SUPPORT:
Use the DbSet extension: AddTemporalSupport to create the 'History' schema and relative temporal tables.
- GET GetHistoricItems => items list in a specific period (DateTime from?, DateTime to)
- GET GetHistoricItem => items list in a specific period for a specific key (TKey id, DateTime from?, DateTime to)
*** Magic Methods ***
- GET GetChangedItem => Get ONLY the CHANGED items list in a specific period (DateTime from?, DateTime to)
- GET GetChangedItems => Get ONLY the CHANGED items list in a specific period for a specific key (TKey id, DateTime from?, DateTime to
- GET GetDeletedItems => Get ONLY the DELETED items list in a specific period (DateTime from?, DateTime to
SAMPLE CALLS:
[GET] /MyDtoController => List of DTO's
[GET] /MyController/1 => Item with key = 1
[GET] /MyDtoController/GetHistoricItems => List of historical DTO's
[GET] /MyDtoController/GetHistoricItem?id=1 => List of historical DTO's with PK = 1