NHUnit 1.0.0
See the version list below for details.
dotnet add package NHUnit --version 1.0.0
NuGet\Install-Package NHUnit -Version 1.0.0
<PackageReference Include="NHUnit" Version="1.0.0" />
<PackageVersion Include="NHUnit" Version="1.0.0" />
<PackageReference Include="NHUnit" />
paket add NHUnit --version 1.0.0
#r "nuget: NHUnit, 1.0.0"
#:package NHUnit@1.0.0
#addin nuget:?package=NHUnit&version=1.0.0
#tool nuget:?package=NHUnit&version=1.0.0
NHUnit
NHUnit is a simple but powerful Unit of Work and Repository pattern implementation for NHibernate which fixes proxy issues and simplifies child nodes loading. NHUnit provides sync and async versions for each method.
Eager loading
Using lambda expressions you can specify which child properties should be populated. The framework will determine the fastest approach to load the data: using join, future queries or by using batch fetching. Depending on the number of returned rows and the depth you might need to finetune your queries, but in most of the cases the framework takes the best decision.
var customer = await _dbContext.Customers.Get(customerId) //returns a wrapper to configure the query
.Include(c => c.Addresses.Single().Country, //include Addresses and Country
c => c.PhoneNumbers.Single().PhoneNumberType) //include all PhoneNumbers with PhoneNumberType
.Unproxy() //instructs the framework to strip all the proxy classes when the Value is returned
.Deferred() //instructs the framework to delay execution
.ValueAsync(token); //this is where the query gets executed
The expression c.Addresses.Single().Country
will load all the nested child objects.
Addresses
is a colection and you need to use Addresses.Single()
to include the nested children. The whole collection will be populated, not just the first item.
Unproxy
You can use IUnitOfWork.Unproxy, ISingleEntityWrapper.Unproxy or IEntityListWrapper.Unproxy
var customer = await _dbContext.Customers
.Get(customerId) //returns a wrapper to configure the query
.Unproxy() //instructs the framework to strip all the proxy classes when the Value is returned
.ValueAsync(token); //this is where the query gets executed
Transactions
IUnitOfWork exposes:
- BeginTransaction
- CommitTransactionAsync - pushes changes and commits transaction
- RollbackTransactionAsync
- SaveChangesAsync - pushes changes to DB but doesn't commit transaction (if any)
- ClearCache - evict all loaded instances and cancel all pending saves, updates and deletions
Procedures/Queries
In some rare cases you need to execute your own queries and NHUnit provides this functionality:
- ExecuteListAsync
- ExecuteScalarAsync
- ExecuteNonQueryAsync
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 was computed. 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. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. 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.0
- Microsoft.AspNetCore.Server.Kestrel.Core (>= 2.1.1)
- NHibernate (>= 5.3.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Release of NHibernate Unit of Work