Smooth.IoC.Dapper.Repository.UnitOfWork
0.1.0-CI00059
See the version list below for details.
dotnet add package Smooth.IoC.Dapper.Repository.UnitOfWork --version 0.1.0-CI00059
NuGet\Install-Package Smooth.IoC.Dapper.Repository.UnitOfWork -Version 0.1.0-CI00059
<PackageReference Include="Smooth.IoC.Dapper.Repository.UnitOfWork" Version="0.1.0-CI00059" />
paket add Smooth.IoC.Dapper.Repository.UnitOfWork --version 0.1.0-CI00059
#r "nuget: Smooth.IoC.Dapper.Repository.UnitOfWork, 0.1.0-CI00059"
// Install Smooth.IoC.Dapper.Repository.UnitOfWork as a Cake Addin #addin nuget:?package=Smooth.IoC.Dapper.Repository.UnitOfWork&version=0.1.0-CI00059&prerelease // Install Smooth.IoC.Dapper.Repository.UnitOfWork as a Cake Tool #tool nuget:?package=Smooth.IoC.Dapper.Repository.UnitOfWork&version=0.1.0-CI00059&prerelease
I made this project to fix the contradictory concepts behind the Repository and UnitOfWork patterns together with using inversition of control / dependancy injection. Also i wanted to make the resolving of sessions (IDbConnection) and UnitOFWork's (IDbTransaction) automatically connection / begin transaction on creation, and disconnect/commit on disposal.
Also i wanted the usage of the session and uow to become nice and simple.
This should cover 97% of your needs. But i have also insured the the Session and UoW types extend the ADO base interfaces, so you can basically do anything you like with the session / uow, because they are IDbConnection and IDbTransaction.
I have tried to insure it is as bare bones as possible. Only adding the system libraries needed and Dapper + Dapper.FASTCrud. The IoC of your choice is not included in the package,
but i have made example registrations for the "majors" look on the project site.
*So far there are examples of Autofact, Castle.Windsor, Ninject, Simpleinjector, StructureMap, and Unity.*
Included interfaces with abstractions:
1. **IDbFactory** is a simple interface that you register with your IoC. It can create/spwan ISession's and IUntOfWork's. But primary used in code to spawn sessions.
2. **ISession<TDatabase>** (and Session<TDatabase> abstraction): Extends IDbConnection. You use it to extend your Database connection / Session type. Yours session classes
and interfaces require a connection string. So If you have multiple database connections, you need 1 ISession and Session extended Interface and class per database. When the session is
created by the factory it connects to the database, when it disposes it discontects and disposes. For Castle Windsor it also untracks the object. You can use the session for any IDbConnection or dapper (or extension) framework you like, as ISession extends IDbConnection ;-).
3. **IUnitOfWork** (and UnitOfWork): Extends IDbTransaction. You don't need to extend anything with this. When you have created a session in you code, you can create a uow from the session. Then the session is created by the factory it begins a transaction (isolation i a parameter), when it disposes it commits (roleback on exception) and disposes. For Castle Windsor it also untracks the object. You can use the transaction for any IDbTransaction work you like as
IUnitOfWork extends IDbTransaction ;-).
4. **IRepository<TSession, TEntity, TPk>** (Repository<TSession, TEntity, TPk> abstraction): Is a default repository that you extend with your own repository for each of
the entities you want a repository for. There as some built in methods for GetAll, Get, and SaveOrUpdate. You can add the methods you need for your entity using any IDbConnection framework.
have used [dapper-dot-net](https://github.com/StackExchange/dapper-dot-net) and [dapper.FastCRUD](https://github.com/MoonStorm/Dapper.FastCRUD) for the quering.
5. **IEntity<TPk>**: An interface for your Entities so FastCRUD GetKey works in Repositories. To use this your table / entity should always have and Id column as Pk in
what every type you like (its a generic :-).
6. **IRepositoryBase** (and RepositoryBase<TEntity> abstraction): This is a vanilla base repository, you can use it if you do not want to use Dapper or Dapper.FastCRUD
and/or IEntity interface. It includes an protected method to set the dialect which you will need to do, if you want to use FastCRUD but without the IEntity interface.
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. |
.NET Core | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.6 is compatible. netstandard2.0 was computed. netstandard2.1 was computed. |
.NET Framework | net452 is compatible. net46 was computed. net461 is compatible. 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 | tizen30 was computed. 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. |
-
.NETFramework 4.5
- Dapper (>= 1.50.2)
- Dapper.FastCrud (>= 2.4.1)
- StringInterpolationBridge (>= 0.9.1)
-
.NETFramework 4.6
- Dapper (>= 1.50.2)
- Dapper.FastCrud (>= 2.4.1)
-
.NETStandard 1.6
- Dapper (>= 1.50.2)
- System.ComponentModel.Annotations (>= 4.1.0)
- System.ComponentModel.TypeConverter (>= 4.1.0)
- System.Data.Common (>= 4.1.0)
- System.Reflection.Extensions (>= 4.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.