TanvirArjel.EFCore.GenericRepository 3.1.2

This library is an almost perfect Generic Repository implementation for EF Core ORM which will remove developers' pain to write repository layer for each .NET Core and .NET project.

This library includes the following notable features:

1. This library can be run on any .NET Core or .NET application which has .NET Standard 2.0 and .NET Standard 2.1 support.

2. It’s providing the Generic Repository with and without Unit of Work pattern.

3. It has all the required methods to query your data in whatever way you want without getting IQueryable<T> from the repository.

4. It also has Specification<T> pattern support so that you can build your query dynamically i.e. differed query building.

5. It also has database level projection support for your query.

6. It also has support to run raw SQL command against your relational database.

7. It also has support to choose whether you would like to track your query entity/entities or not.

8. It also has support to reset your EF Core DbContext state whenever you really needed.

9.  Most importantly, it has full Unit Testing support.

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

How do I get started?

First, install the appropriate version of this NuGet package into your project as follows:

For EF Core 2.x.x :

Install-Package TanvirArjel.EFCore.GenericRepository -Version 2.0.2

For EF Core 3.0.x :

Install-Package TanvirArjel.EFCore.GenericRepository -Version 3.0.2

For EF Core >= 3.1.x :

Install-Package TanvirArjel.EFCore.GenericRepository -Version 3.1.2

Then in the ConfirugeServices method of the Startup class:

public void ConfigureServices(IServiceCollection services)
{
    string connectionString = Configuration.GetConnectionString("RepositoryDbConnection");
    services.AddDbContext<DemoDbContext>(option => option.UseSqlServer(connectionString));

    services.AddGenericRepository<DemoDbContext>(); // Call it just after registering your DbConext.
}

Usage:

Now inject IUnitOfWork interface in your relevant class constructor and use as follows:

public class EmployeeService
{
   private readonly IRepository _repository;

   public EmployeeService(IRepository repository)
   {
      _repository = repository;
   }
 
   public async Task<Employee> GetEmployeeAsync(int employeeId)
   {
      Employee employee = await _repository.GetEntityByIdAsync<Employee>(1);
      return employee;
   }
}

To see more details documentation, please visit GitHub Repository

How do I get started?

First, install the appropriate version of this NuGet package into your project as follows:

For EF Core 2.x.x :

Install-Package TanvirArjel.EFCore.GenericRepository -Version 2.0.2

For EF Core 3.0.x :

Install-Package TanvirArjel.EFCore.GenericRepository -Version 3.0.2

For EF Core >= 3.1.x :

Install-Package TanvirArjel.EFCore.GenericRepository -Version 3.1.2

Then in the ConfirugeServices method of the Startup class:

public void ConfigureServices(IServiceCollection services)
{
    string connectionString = Configuration.GetConnectionString("RepositoryDbConnection");
    services.AddDbContext<DemoDbContext>(option => option.UseSqlServer(connectionString));

    services.AddGenericRepository<DemoDbContext>(); // Call it just after registering your DbConext.
}

Usage:

Now inject IUnitOfWork interface in your relevant class constructor and use as follows:

public class EmployeeService
{
   private readonly IRepository _repository;

   public EmployeeService(IRepository repository)
   {
      _repository = repository;
   }
 
   public async Task<Employee> GetEmployeeAsync(int employeeId)
   {
      Employee employee = await _repository.GetEntityByIdAsync<Employee>(1);
      return employee;
   }
}

To see more details documentation, please visit GitHub Repository

Release Notes

1. This release added support of generic repository through generic methods for more simplicity.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
3.1.2 73 5/20/2020
3.1.1 100 4/25/2020
3.1.0 79 4/23/2020
3.0.2 104 5/20/2020
3.0.1 80 4/25/2020
3.0.0 78 4/23/2020
2.0.2 92 5/20/2020
2.0.1 80 4/25/2020
2.0.0 69 4/23/2020