Thanacio
Thanacio
CC#
Created by Thanacio on 4/9/2025 in #help
Dapper - Unit of work between 2 repositories
fwiw I think I had the right idea but ended up messing the execution and that cost me a job offer, but oh well 😐
27 replies
CC#
Created by Thanacio on 4/9/2025 in #help
Dapper - Unit of work between 2 repositories
thank you again for your help! probably saved my life
27 replies
CC#
Created by Thanacio on 4/9/2025 in #help
Dapper - Unit of work between 2 repositories
I even separated a concern to a new service
27 replies
CC#
Created by Thanacio on 4/9/2025 in #help
Dapper - Unit of work between 2 repositories
alright, it's done! 😄
27 replies
CC#
Created by Thanacio on 4/9/2025 in #help
Dapper - Unit of work between 2 repositories
brb
27 replies
CC#
Created by Thanacio on 4/9/2025 in #help
Dapper - Unit of work between 2 repositories
I'll keep you posted when I work it out 😄
27 replies
CC#
Created by Thanacio on 4/9/2025 in #help
Dapper - Unit of work between 2 repositories
literally
27 replies
CC#
Created by Thanacio on 4/9/2025 in #help
Dapper - Unit of work between 2 repositories
you're a lifesaver dude
27 replies
CC#
Created by Thanacio on 4/9/2025 in #help
Dapper - Unit of work between 2 repositories
and is it used by the service?
27 replies
CC#
Created by Thanacio on 4/9/2025 in #help
Dapper - Unit of work between 2 repositories
I think there is one in the codebase
27 replies
CC#
Created by Thanacio on 4/9/2025 in #help
Dapper - Unit of work between 2 repositories
injecting it, then use it
27 replies
CC#
Created by Thanacio on 4/9/2025 in #help
Dapper - Unit of work between 2 repositories
making an intermediate class called UnitOfWork
27 replies
CC#
Created by Thanacio on 4/9/2025 in #help
Dapper - Unit of work between 2 repositories
ohhh I think I know where you're getting at
27 replies
CC#
Created by Thanacio on 4/9/2025 in #help
Dapper - Unit of work between 2 repositories
yes!
27 replies
CC#
Created by Thanacio on 4/9/2025 in #help
Dapper - Unit of work between 2 repositories
because right now the only place in our code responsible for commiting the ongoing transaction lives in repository methodss
27 replies
CC#
Created by Thanacio on 4/9/2025 in #help
Dapper - Unit of work between 2 repositories
I was wondering if lifting the Commit/Rollback responsibility to the service layer is a good/bad practice for it
27 replies
CC#
Created by Thanacio on 4/9/2025 in #help
Dapper - Unit of work between 2 repositories
This is taken from the Dapper Repository
27 replies
CC#
Created by Thanacio on 4/9/2025 in #help
Dapper - Unit of work between 2 repositories
I can't because it's proprietary but I can approximate it. Basically, so far in the codebase, the unit of work is implemented like that (code not mine):
public async Task<int> CreateOrderAsync()
{
// UseTransaction begins the transaction that will get shared
UseTransaction(_connection.BeginTransaction());

try
{
// dapper stuff

foreach (var item in items)
{
// do stuff
}

// transaction gets commited at the end
_transaction.Commit();
return orderId;
}
catch
{
_transaction.Rollback();
throw;
}
}
public async Task<int> CreateOrderAsync()
{
// UseTransaction begins the transaction that will get shared
UseTransaction(_connection.BeginTransaction());

try
{
// dapper stuff

foreach (var item in items)
{
// do stuff
}

// transaction gets commited at the end
_transaction.Commit();
return orderId;
}
catch
{
_transaction.Rollback();
throw;
}
}
27 replies
CC#
Created by Thanacio on 4/4/2025 in #help
ASP.NET MVC - need opinion for viewmodel properties
have a good day/night!
57 replies
CC#
Created by Thanacio on 4/4/2025 in #help
ASP.NET MVC - need opinion for viewmodel properties
thank you again for your help!
57 replies