TanvirArjel.EFCore.GenericRepository
6.0.0-preview1
See the version list below for details.
dotnet add package TanvirArjel.EFCore.GenericRepository --version 6.0.0-preview1
NuGet\Install-Package TanvirArjel.EFCore.GenericRepository -Version 6.0.0-preview1
<PackageReference Include="TanvirArjel.EFCore.GenericRepository" Version="6.0.0-preview1" />
paket add TanvirArjel.EFCore.GenericRepository --version 6.0.0-preview1
#r "nuget: TanvirArjel.EFCore.GenericRepository, 6.0.0-preview1"
// Install TanvirArjel.EFCore.GenericRepository as a Cake Addin #addin nuget:?package=TanvirArjel.EFCore.GenericRepository&version=6.0.0-preview1&prerelease // Install TanvirArjel.EFCore.GenericRepository as a Cake Tool #tool nuget:?package=TanvirArjel.EFCore.GenericRepository&version=6.0.0-preview1&prerelease
Become a Patron
If you want to encourage me to contribute to this repository more frequently. Then please become a patron on here: https://www.patreon.com/user?u=80125977
Thanks in advance.
EF Core Generic Repository
This library is a Generic Repository implementation for EF Core ORM which will remove developers' pain to write repository layer for each .NET Core and .NET project.
⭐ Giving a star
If you find this library useful, please don't forget to encouraging me to do such more stuffs by giving a star to this repository. Thank you.
🔥 What's new
Pagination Support:
PaginationSpecification<Employee> specification = new PaginationSpecification<Employee>();
specification.Conditions.Add(e => e.Name.Contains("Ta"));
specification.PageIndex = 1;
specification.PageSize = 10;
PaginatedList<EmployeeDto> paginatedList = await _repository.GetListAsync(specification, e => new EmployeeDto
{
Id = e.Id
Name = e.Name,
DepartmentName = e.DepartmentName
});
Free raw SQL support:
List<string> search = new List<string>() { "Tanvir", "Software" };
string sqlQuery = "Select EmployeeName, DepartmentName from Employee Where EmployeeName LIKE @p0 + '%' and DepartmentName LIKE @p1 + '%'";
List<EmployeeDto> items = await _repository.GetFromRawSqlAsync<EmployeeDto>(sqlQuery, search);
⚙️ This library includes following notable features:
This library can be run on any .NET Core or .NET application which has .NET Core 3.1, .NET Standard 2.1 and .NET 5.0+ support.
It’s providing the Generic Repository with database transaction support.
It has all the required methods to query your data in whatever way you want without getting IQueryable<T> from the repository.
It also has
Specification<T>
pattern support so that you can build your query dynamically i.e. differed query building.It also has database level projection support for your query.
It also has support to run raw SQL command against your relational database.
It also has support to choose whether you would like to track your query entity/entities or not.
It also has support to reset your EF Core DbContext state whenever you really needed.
Most importantly, it has full Unit Testing support.
Pagination support.
Free raw SQL query support both for complex type and primitive types.
✈️ How do I get started?
For full version (both query and command support):
First install the latest version of TanvirArjel.EFCore.GenericRepository
nuget package into your project as follows:
Package Manager Console:
Install-Package TanvirArjel.EFCore.GenericRepository
.NET CLI:
dotnet add package TanvirArjel.EFCore.GenericRepository
Then in the ConfirugeServices
method of the Startup
class:
public void ConfigureServices(IServiceCollection services)
{
// For single DbContext
services.AddGenericRepository<YourDbContext>();
// If multiple DbContext
services.AddGenericRepository<YourDbContext1>();
services.AddGenericRepository<YourDbContext2>();
}
For query version only:
First install the latest version of TanvirArjel.EFCore.QueryRepository
nuget package into your project as follows:
Package Manager Console:
Install-Package TanvirArjel.EFCore.QueryRepository
.NET CLI:
dotnet add package TanvirArjel.EFCore.QueryRepository
Then in the ConfirugeServices
method of the Startup
class:
public void ConfigureServices(IServiceCollection services)
{
// For single DbContext
services.AddQueryRepository<YourDbContext>();
// For multiple DbContext
services.AddQueryRepository<YourDbContext1>();
services.AddQueryRepository<YourDbContext2>();
}
🛠️ Usage: Query
public class EmployeeService
{
// For query version, please use `IQueryRepository` instead of `IRepository`
private readonly IRepository _repository; // If single DbContext
private readonly IRepository<YourDbContext1> _dbConext1Repository; // If multiple DbContext
public EmployeeService(IRepository repository, IRepository<YourDbContext1> dbConext1Repository)
{
_repository = repository;
_dbConext1Repository = dbConext1Repository;
}
public async Task<Employee> GetEmployeeAsync(int employeeId)
{
Employee employee = await _repository.GetByIdAsync<Employee>(1);
return employee;
}
}
🛠️ Usage: Command
public class EmployeeService
{
private readonly IRepository _repository; // If single DbContext
private readonly IRepository<YourDbContext1> _dbConext1Repository; // If multiple DbContext
public EmployeeService(IRepository repository, IRepository<YourDbContext1> dbConext1Repository)
{
_repository = repository;
_dbConext1Repository = dbConext1Repository;
}
public async Task<int> CreateAsync(Employee employee)
{
await _repository.AddAsync(employee);
await _repository.SaveChangesAsync();
return employee.Id;
}
}
For more detail documentaion, please visit Documentation Wiki
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. 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 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
- Microsoft.EntityFrameworkCore.Relational (>= 5.0.17)
- TanvirArjel.EFCore.QueryRepository (>= 1.5.0-preview1)
-
net6.0
- Microsoft.EntityFrameworkCore.Relational (>= 6.0.10)
- TanvirArjel.EFCore.QueryRepository (>= 1.5.0-preview1)
-
net7.0
- Microsoft.EntityFrameworkCore.Relational (>= 7.0.0-rc.2.22472.11)
- TanvirArjel.EFCore.QueryRepository (>= 1.5.0-preview1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on TanvirArjel.EFCore.GenericRepository:
Package | Downloads |
---|---|
Shaesk.Domain
Package For Shaesk Domain |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on TanvirArjel.EFCore.GenericRepository:
Repository | Stars |
---|---|
TanvirArjel/CleanArchitecture
This repository contains the implementation of domain-driven design and clear architecture in ASP.NET Core.
|
|
YSGStudyHards/DotNetExercises
⚔【DotNetGuide专栏C#/.NET/.NET Core编程技巧练习集】C#/.NET/.NET Core编程常用语法、算法、技巧、中间件、类库、工作业务实操练习集,配套详细的文章教程讲解,助你快速掌握C#/.NET/.NET Core中各种编程常用语法、算法、技巧、中间件、类库、工作业务实操等等。
|
Version | Downloads | Last updated |
---|---|---|
6.0.4 | 7,694 | 1/13/2024 |
6.0.3 | 2,525 | 1/1/2024 |
6.0.2 | 1,506 | 11/20/2023 |
6.0.1 | 2,635 | 9/9/2023 |
6.0.0 | 11,014 | 11/9/2022 |
6.0.0-preview1 | 149 | 10/19/2022 |
5.9.1 | 6,791 | 8/21/2022 |
5.9.0 | 14,440 | 6/9/2022 |
5.8.1 | 523 | 6/7/2022 |
5.8.0 | 11,961 | 11/12/2021 |
5.7.0 | 637 | 10/6/2021 |
5.6.0 | 586 | 8/13/2021 |
5.5.0 | 4,062 | 4/7/2021 |
5.4.0 | 256 | 3/30/2021 |
5.3.0 | 380 | 3/27/2021 |
5.2.2 | 734 | 2/12/2021 |
5.2.1 | 417 | 2/8/2021 |
5.2.0 | 374 | 2/7/2021 |
5.1.0 | 497 | 1/14/2021 |
5.0.0 | 663 | 11/12/2020 |
3.1.2 | 1,647 | 5/20/2020 |
3.1.1 | 556 | 4/25/2020 |
3.1.0 | 520 | 4/23/2020 |
3.0.2 | 572 | 5/20/2020 |
3.0.1 | 509 | 4/25/2020 |
3.0.0 | 520 | 4/23/2020 |
2.0.2 | 562 | 5/20/2020 |
2.0.1 | 491 | 4/25/2020 |
2.0.0 | 489 | 4/23/2020 |
1. dotNET 7.0 support has been added.
2. Few breaking changes in command methods.