Prakrishta.Data 1.0.0

Generic Repository and Unit of work pattern with EF.Core

Install-Package Prakrishta.Data -Version 1.0.0
dotnet add package Prakrishta.Data --version 1.0.0
<PackageReference Include="Prakrishta.Data" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Prakrishta.Data --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Prakrishta.Data

Generic Repository and Unit of work pattern with EF.Core

Package installer:

Install-Package Prakrishta.Data

Easy to create Unit of work and repository.

IUnitOfWork unitOfWork = new UnitOfWork<DatabaseContext>(databaseContext);
var readRepository = unitOfWork.GetReadRepository<User>();

if need to create CRUD repository,

var readRepository = unitOfWork.GetCrudRepository<User>();

The unit of work can be injected using any IoC containers as well. There is an extension to add Unit of work with .net core middleware.

services.AddUnitOfWork<urdbcontextclass>();

Once unit of work is added to middleware, can be injected to controller or whereever requires. The following example shows construction injection in controller and it's usage

private readonly IUnitOfWork<UserContext> _uow;
public UserController(IUnitOfWork<UserContext> uow)
{
    this._uow = uow;
}

[HttpGet]
public ActionResult<IEnumerable<User>> Get()
{
    var userList = this._uow.GetReadRepository<User>().GetAll();
}

The repository has both synchronous and asynchronous methods and also supports pagination as well. The associated tables can also queried through "Included" parameter, for example if user detail requires relevant entity "Address" as well then the following code snippet will do the job.

[HttpGet]
public ActionResult<IEnumerable<User>> Get()
{
    var userList = this._uow.GetReadRepository<User>().GetAll("Address");
}

All of the read methods support filtering and has support for sorting, record change tracking.

The code base is licensed under open source, please feel free to use it in your project or edit as per your need.

Prakrishta.Data

Generic Repository and Unit of work pattern with EF.Core

Package installer:

Install-Package Prakrishta.Data

Easy to create Unit of work and repository.

IUnitOfWork unitOfWork = new UnitOfWork<DatabaseContext>(databaseContext);
var readRepository = unitOfWork.GetReadRepository<User>();

if need to create CRUD repository,

var readRepository = unitOfWork.GetCrudRepository<User>();

The unit of work can be injected using any IoC containers as well. There is an extension to add Unit of work with .net core middleware.

services.AddUnitOfWork<urdbcontextclass>();

Once unit of work is added to middleware, can be injected to controller or whereever requires. The following example shows construction injection in controller and it's usage

private readonly IUnitOfWork<UserContext> _uow;
public UserController(IUnitOfWork<UserContext> uow)
{
    this._uow = uow;
}

[HttpGet]
public ActionResult<IEnumerable<User>> Get()
{
    var userList = this._uow.GetReadRepository<User>().GetAll();
}

The repository has both synchronous and asynchronous methods and also supports pagination as well. The associated tables can also queried through "Included" parameter, for example if user detail requires relevant entity "Address" as well then the following code snippet will do the job.

[HttpGet]
public ActionResult<IEnumerable<User>> Get()
{
    var userList = this._uow.GetReadRepository<User>().GetAll("Address");
}

All of the read methods support filtering and has support for sorting, record change tracking.

The code base is licensed under open source, please feel free to use it in your project or edit as per your need.

Version History

Version Downloads Last updated
1.0.0 71 2/7/2019