DK.GenericLibrary
1.2.0
See the version list below for details.
dotnet add package DK.GenericLibrary --version 1.2.0
NuGet\Install-Package DK.GenericLibrary -Version 1.2.0
<PackageReference Include="DK.GenericLibrary" Version="1.2.0" />
<PackageVersion Include="DK.GenericLibrary" Version="1.2.0" />
<PackageReference Include="DK.GenericLibrary" />
paket add DK.GenericLibrary --version 1.2.0
#r "nuget: DK.GenericLibrary, 1.2.0"
#:package DK.GenericLibrary@1.2.0
#addin nuget:?package=DK.GenericLibrary&version=1.2.0
#tool nuget:?package=DK.GenericLibrary&version=1.2.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 | net8.0 is compatible. 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. net9.0 was computed. 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. net10.0 was computed. 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. |
-
net8.0
- Microsoft.EntityFrameworkCore (>= 9.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Updated all Get calls to use AsNoTracking