For now when I want to begin a transactional uow, I need this code:
using (var uow = _unitOfWorkManager.Begin(new AbpUnitOfWorkOptions
{
IsTransactional = true
}))
{
}
It doesn't look simple enough.
I have two ways for this problem:
BeginTransactional(): public static IUnitOfWork Begin([NotNull] this IUnitOfWorkManager unitOfWorkManager, bool requiresNew = false)
{
Check.NotNull(unitOfWorkManager, nameof(unitOfWorkManager));
return unitOfWorkManager.Begin(new AbpUnitOfWorkOptions(), requiresNew);
}
public static IUnitOfWork BeginTransactional([NotNull] this IUnitOfWorkManager unitOfWorkManager, bool requiresNew = false)
{
Check.NotNull(unitOfWorkManager, nameof(unitOfWorkManager));
return unitOfWorkManager.Begin(new AbpUnitOfWorkOptions {IsTransactional = true}, requiresNew);
}
IsTransactional.If you let ABP to handle it, ABP disables transaction for GET, enables for POST, PUT and others.
It will reduce the chance of setting IsTransactional manually.
What do you think? @hikalkan
Or you can add an IsTransactionalparameter to the Beginmethod, which defaults to false.
public static IUnitOfWork Begin([NotNull] this IUnitOfWorkManager unitOfWorkManager,
bool requiresNew = false,
bool isTransactional = false)
{
}
Most helpful comment
Or you can add an
IsTransactionalparameter to theBeginmethod, which defaults tofalse.