DK.GenericLibrary
2.0.0
dotnet add package DK.GenericLibrary --version 2.0.0
NuGet\Install-Package DK.GenericLibrary -Version 2.0.0
<PackageReference Include="DK.GenericLibrary" Version="2.0.0" />
<PackageVersion Include="DK.GenericLibrary" Version="2.0.0" />
<PackageReference Include="DK.GenericLibrary" />
paket add DK.GenericLibrary --version 2.0.0
#r "nuget: DK.GenericLibrary, 2.0.0"
#:package DK.GenericLibrary@2.0.0
#addin nuget:?package=DK.GenericLibrary&version=2.0.0
#tool nuget:?package=DK.GenericLibrary&version=2.0.0
Package primarily made for ASP.NET Applications, but can work with any project utilizing ServiceProviders.
!Important The solutions UpdateItem(s) methods can dynamically register changes of 1 nested collection, anything past that will need either a custom extension or to simply pass it directly into the parameter. As the collection items are part of the DbSet it will be able to update correctly.
This package provides a fully generic repository to fulfill the common CRUD actions with Entity Framework, without writing the same 8 lines 15 times per repository.
The gist of the package is, that by registering the Interface and/or class implementation, as well as the IDbContextFactory with a given context, each and every method in this package will create and dispose a new context every time.
All the (Async at least) methods has examples of how to use it in the documentation/mouseover.
How to use: ASP.Net core
Register services
Only register the one you need, newly added Service extension to quickly register the services.

It's important that the Context is registered as a IDbContextFactory as this is used to handle instantiation and disposal of context instances.
Inject repository into a service or wherever needed

Define methods and use the generic methods to retrieve what you need
Example:

Currently tested all methods and registrations of Async and regular repositories.

| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.EntityFrameworkCore (>= 10.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Updated for EF Core 10.0.2 (newest compatible with PostgreSQL)