本文整理汇总了C#中IUnitOfWorkFactory.Create方法的典型用法代码示例。如果您正苦于以下问题:C# IUnitOfWorkFactory.Create方法的具体用法?C# IUnitOfWorkFactory.Create怎么用?C# IUnitOfWorkFactory.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IUnitOfWorkFactory
的用法示例。
在下文中一共展示了IUnitOfWorkFactory.Create方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
public static IUnitOfWork Start()
{
_innerUnitOfWorkFactory = ServiceLocator.Current.GetInstance<IUnitOfWorkFactory>();
_innerUnitOfWork = _innerUnitOfWorkFactory.Create();
return Current;
}
示例2: Start
public static IUnitOfWork Start()
{
if (_innerUnitOfWork != null)
throw new InvalidOperationException("You cannot start more than one unit of work at the same time.");
_unitOfWorkFactory = Context.Current.UnitOfWorkFactory;
_innerUnitOfWork = _unitOfWorkFactory.Create();
return _innerUnitOfWork;
}
示例3: UnitOfWorkScopeTransaction
/// <summary>
/// Overloaded Constructor.
/// Creates a new instance of the <see cref="UnitOfWorkScopeTransaction"/> that takes in a
/// <see cref="IUnitOfWorkFactory"/> instance that is responsible for creating instances of <see cref="IUnitOfWork"/> and
/// a <see cref="IDbConnection"/> that is used by the instance to connect to the data store.
/// </summary>
/// <param name="unitOfWorkFactory">The <see cref="IUnitOfWorkFactory"/> implementation that is responsible
/// for creating instances of <see cref="IUnitOfWork"/> instances.</param>
/// <param name="isolationLevel">One of the values of <see cref="IsolationLevel"/> that specifies the transaction
/// isolation level of the <see cref="UnitOfWorkScopeTransaction"/> instance.</param>
public UnitOfWorkScopeTransaction(IUnitOfWorkFactory unitOfWorkFactory, IsolationLevel isolationLevel)
{
Guard.Against<ArgumentNullException>(unitOfWorkFactory == null,
"A valid non-null instance that implements the IUnitOfWorkFactory is required.");
_transactionID = new Guid();
_transactionRolledback = false;
_disposed = false;
_unitOfWork = unitOfWorkFactory.Create();
_runningTransaction = _unitOfWork.BeginTransaction(isolationLevel);
_isolationLevel = isolationLevel;
_attachedScopes = new Stack<UnitOfWorkScope>();
}
示例4: SetupContext
public void SetupContext()
{
_factory = _mocks.DynamicMock<IUnitOfWorkFactory>();
_unitOfWork = _mocks.DynamicMock<IUnitOfWork>();
_session = _mocks.DynamicMock<ISession>();
InstrumentUnitOfWork();
_mocks.BackToRecordAll();
SetupResult.For(_factory.Create()).Return(_unitOfWork);
SetupResult.For(_factory.CurrentSession).Return(_session);
_mocks.ReplayAll();
}
示例5: SetupContext
public void SetupContext() {
_factory = _mocks.DynamicMock<IUnitOfWorkFactory>();
_unitOfWork = _mocks.DynamicMock<IUnitOfWork>();
_session = _mocks.DynamicMock<ISession>();
var fieldInfo = typeof(UnitOfWork).GetField("_unitOfWorkFactory",
BindingFlags.Static | BindingFlags.SetField | BindingFlags.NonPublic);
fieldInfo.SetValue(null, _factory);
_mocks.BackToRecordAll();
SetupResult.For(_factory.Create()).Return(_unitOfWork);
SetupResult.For(_factory.CurrentSession).Return(_session);
_mocks.ReplayAll();
}
示例6: SetUpContext
public void SetUpContext()
{
ResetUnitOfWork();
_factory = _mocks.DynamicMock<IUnitOfWorkFactory>();
_unitOfWork = _mocks.DynamicMock<IUnitOfWork>();
_session = _mocks.DynamicMock<ISession>();
//var fieldInfo = typeof(UnitOfWork).GetField("_innerUnitOfWork",
// BindingFlags.Static | BindingFlags.SetField | BindingFlags.NonPublic);
//fieldInfo.SetValue(null, null);
InstrumentUnitOfWork();
_mocks.BackToRecordAll();
SetupResult.For(_factory.Create(dbKey)).Return(_unitOfWork);
SetupResult.For(_factory.GetCurrentSession(dbKey)).Return(_session);
SetupResult.For(_unitOfWork.DatabaseKey).Return(dbKey);
_mocks.ReplayAll();
}
示例7: CategoryService
public CategoryService(IUnitOfWorkFactory factory)
{
_unitOfWork = factory.Create();
_repository = _unitOfWork.Repository<Category>();
}
示例8: SubTaskService
public SubTaskService(IUnitOfWorkFactory factory)
{
_unitOfWork = factory.Create();
_taskRepository = _unitOfWork.Repository<Task>();
_repository = _unitOfWork.Repository<SubTask>();
}