23 lines
853 B
C#
Executable File
23 lines
853 B
C#
Executable File
using Microsoft.Extensions.DependencyInjection;
|
|
using Opsoft.NetCore.O3App.Domain;
|
|
using Opsoft.NetCore.O3App.Shared;
|
|
|
|
namespace Opsoft.NetCore.O3App.Infrastructure.Repositories
|
|
{
|
|
[MapTo(typeof(IDapperUnitOfWorkFactory), ServiceLifetime.Transient)]
|
|
internal class DapperUnitOfWorkFactory : IDapperUnitOfWorkFactory
|
|
{
|
|
private readonly IDapperContextFactory dapperContextFactory;
|
|
|
|
public DapperUnitOfWorkFactory(IDapperContextFactory dapperContextFactory)
|
|
{
|
|
this.dapperContextFactory = Guard.ArgumentNotNull(dapperContextFactory, nameof(dapperContextFactory));
|
|
}
|
|
|
|
public IDapperUnitOfWork Create(string dbName = Constants.DatabaseNames.Default, bool @readonly = false)
|
|
{
|
|
return new DapperUnitOfWork(dapperContextFactory.Create(dbName, @readonly));
|
|
}
|
|
}
|
|
}
|