I am building ASP.NET MVC 5 application.
I read about Repository and Unit of Work (UoW) Patterns here.
These examples use Entity Framework which adds a high-level of abstraction itself.
I am using ADO.NET and not EF. I want to know:
I've written a blog post which teaches you on how to write driver independent code and how to implement Uow/Repository pattern with plain ADO.NET.
It's a bit too long to include in this answer, but basically the IDbtransaction
will represent your Unit oF Work (or be contained in one) and every repository will take the transaction or UoW in it's constructor.
To create a command using a IDbTransaction
using (var cmd = transaction.Connection.CreateCommand())
{
cmd.Transaction = transaction;
//do a CRUD operation here.
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With