0

I am using the below Unit of work implementation in my application. URL reference :How to implement Unit Of Work pattern with Dapper?

This is working fine with single thread application. But if i want to use same code for multi thread application, then its creating a problem.

Example: I am creating unit of work object with AddScoped services.AddScoped<IUnitOfWork, UnitOfWork>();

Old Transaction object will be replaced by new transaction object, when more than one thread calling unit of work Begin() method in single web request.

Anbazhagan
  • 39
  • 6
  • What is the error your seeing? Can you post the stack trace for example? Or maybe some of the source code – Mark Davies Jan 02 '20 at 10:35
  • Are you still working on that? I've created a simple unit of work implementation on top of Dapper, with some basic CQS in mind. https://github.com/giangcoi48k/Dapper.CQS. Please take a look and see if it can apply to your project. – Minh Giang Nov 30 '21 at 18:51

1 Answers1

0

AddScoped create one instance per request, so, if you need execute many threads in a single request where each thread run into a transaction,using this unitofwork code, I think you'll need to update your unitofwork code to manage one connection per thread

agpcardoso
  • 27
  • 7