Generic.RepositoryAsync.EFCore
1.0.0
Sorry for the troubles, I've been working the best I can do to help you codding better and more cleaning.
See the version list below for details.
Requires NuGet 2.0 or higher.
dotnet add package Generic.RepositoryAsync.EFCore --version 1.0.0
NuGet\Install-Package Generic.RepositoryAsync.EFCore -Version 1.0.0
<PackageReference Include="Generic.RepositoryAsync.EFCore" Version="1.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
paket add Generic.RepositoryAsync.EFCore --version 1.0.0
#r "nuget: Generic.RepositoryAsync.EFCore, 1.0.0"
// Install Generic.RepositoryAsync.EFCore as a Cake Addin
#addin nuget:?package=Generic.RepositoryAsync.EFCore&version=1.0.0
// Install Generic.RepositoryAsync.EFCore as a Cake Tool
#tool nuget:?package=Generic.RepositoryAsync.EFCore&version=1.0.0
Generic.Repository.EFCore
This is a Generic Repository Async make using EFCore 2.2.4
Code Quality - Master Travis CI - Master
This version is final.
This project has objective to made a CRUD more easily. Adding an extra layer of abstraction in application. This project has building using the best programmation pratices.
Principles used:
- Reactive progammation;
- DRY principle;
- SOLID principles.
Add an generic layer of abstraction in application.
This project is builded in asp.net standard and has the dependencies below:
- Microsoft.EntityFrameworkCore (>= 2.2.4)
V.1.0.0
An new project has born..
DOCS
To use this package is necessary make this steps:
Step 1
On startup project yor will add this
public void ConfigureServices(IServiceCollection services)
{
//You can pass empty parameter on here!!! EX: Commom.SetSizeByLengthProperties("", "");
Commom.SetSizeByLengthProperties("AssemblyName", "Namespace of Entity; Namespace of Filters");
Commom.SaveOnCacheIfNonExists<TypeEntity>();
... rest your code...
Step 2
//Create your own repository, like this sample:
//Interface
public interface ICustomerRepository : IBaseRepositoryAsync<Customer, CustomerFilter>
{
IPage<Customer> CustomerPage(IPageConfig config);
}
//Implementation
public class CustomerRepository : BaseRepositoryAsync<Customer, CustomerFilter>, ICustomerRepository
{
public CustomerRepository(LocalDbContext context) : base(context)
{
//is this necessary
includesString = new List<string>();
//and this...
includesExp = new List<Expression<Func<Customer, object>>>();
}
// If you will use Pagination
public IPage<Customer> CustomerPage(IPageConfig config)
{
return base._context.Set<Customer>().AsNoTracking().ToPage(config);
}
}
//On startup you will add this:
services.AddScoped<ICustomerRepository, CustomerRepository>();
//If you will use auto generation filter you will need implements interface IFilter, like this...
public class CustomerFilter : IFilter...
Step 3
Now you need add your repository on your Controller.... P.S.: This is a sample, if you want you can add repository on your Service layer and add your Service in your Controller, this is a simple sample.
[ApiController]
[Route("api/[controller]")]
public class CustomerController : ControllerBase
{
///....code...
///Filter example
[HttpGet("filter")]
public async Task<ActionResult<List<Customer>>> GetAllFilterAsync([FromQuery]CustomerFilter filter)
{
try
{
var list = await _repo.FilterAllAsync(filter, true);
if (list.Count() < 1)
return NoContent();
return Ok(list);
}
catch (Exception e)
{
return BadRequest($"Message: {e.Message} - StackTrace: {e.StackTrace} {(e.InnerException != null ? "InnerException" + e.InnerException : "")}");
}
}
/// Get All example
[HttpGet]
public async Task<ActionResult<List<Customer>>> GetAllAsync()
{
var list = await _repo.GetAllAsync(true);
if (list.Count() < 1)
return NoContent();
return Ok(list);
}
/// <summary>
/// Get All paginated example
/// </summary>
/// <returns></returns>
[HttpGet("page")]
public ActionResult<Page<Customer>> GetAllPaginated([FromQuery]PageConfig config)
{
try
{
return Ok(_repo.CustomerPage(config));
}
catch (Exception e)
{
return BadRequest($"Message: {e.Message} - StackTrace: {e.StackTrace} {(e.InnerException != null ? "InnerException" + e.InnerException : "")}");
}
}
}
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 | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. 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.0
- Microsoft.EntityFrameworkCore (>= 2.2.4)
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.0.4 | 632 | 2/8/2020 |
V1.0.0 noob