CleanCodeJN.Repository.EntityFramework
2.0.0
dotnet add package CleanCodeJN.Repository.EntityFramework --version 2.0.0
NuGet\Install-Package CleanCodeJN.Repository.EntityFramework -Version 2.0.0
<PackageReference Include="CleanCodeJN.Repository.EntityFramework" Version="2.0.0" />
<PackageVersion Include="CleanCodeJN.Repository.EntityFramework" Version="2.0.0" />
<PackageReference Include="CleanCodeJN.Repository.EntityFramework" />
paket add CleanCodeJN.Repository.EntityFramework --version 2.0.0
#r "nuget: CleanCodeJN.Repository.EntityFramework, 2.0.0"
#addin nuget:?package=CleanCodeJN.Repository.EntityFramework&version=2.0.0
#tool nuget:?package=CleanCodeJN.Repository.EntityFramework&version=2.0.0
Generic Repository Implementation
Repository Abstraction for Entity Framework
This generic Repository implementation for Entity Framework abstracts completely all EF-References from your business layer in a domain driven design manner.
Features
- Ready to use in seconds
- Abstracts all EF specific Code out of your business layer
- Easy to mock and test
- On latest .NET 8.0
How to use
- Add IEntity<T> interfaces to your domain classes
- Add IDataContext Interface to your DBContext class
- Use Extension RegisterRepositories() in your startup class or program.cs
- Inject IRepository<T> in your business layer
- Just use It
Step by step explanation
Add IEntity<T> interfaces to your domain classes:
public class Customer : IEntity<int>
{
public int Id { get; set; }
}
Add IDataContext Interface to your DBContext class:
public partial class MyDbContext : DbContext, IDataContext
{
}
Use Extension RegisterDbContextAndRepositories() in your startup class or program.cs:
// Just register generic repositories and your dbContext which has the IDataContext marker interface
builder.Services.RegisterDbContextAndRepositories<MyDbContext>();
Inject IRepository<TEntity, TKey> (or IIntRepository, IStringRepository, IGuidRepository, ILongRepository) in your business layer:
public class MyService(IRepository<Customer, int> repository)
{
}
Just use it:
List<customer> customerWhoHavePayed = repository
.Query(asNoTracking: true, asSplitQuery: true, includes: x => x.Invoices)
.Where(x => x.Invoice.IsPayed)
.ToList()
Sample Code
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net9.0
- Azure.Identity (>= 1.13.2)
- Microsoft.EntityFrameworkCore (>= 9.0.2)
- Microsoft.EntityFrameworkCore.SqlServer (>= 9.0.2)
- Microsoft.Extensions.Caching.Memory (>= 9.0.2)
- System.Formats.Asn1 (>= 9.0.2)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on CleanCodeJN.Repository.EntityFramework:
Package | Downloads |
---|---|
CleanCodeJN.GenericApis
This CleanCodeJN package streamlines the development of web APIs in .NET applications by providing a robust framework for CRUD operations and facilitating the implementation of complex business logic in a clean and maintainable manner. |
|
CleanCodeJN.GenericApis.ServiceBusConsumer
This CleanCodeJN package for Service Bus simplifies the development of asynchronous microservices by providing a framework that leverages the power of MediatR and IOSP to consume service bus events from topics and execute commands to process these events. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Update to .NET 9.0.