当前位置: 首页>>代码示例>>C#>>正文


C# IUnitOfWorkFactory.Create方法代码示例

本文整理汇总了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;
        }
开发者ID:marufbd,项目名称:Zephyr.NET,代码行数:8,代码来源:UnitOfWorkScope.cs

示例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;
        }
开发者ID:Glareone,项目名称:Bikeworkshop,代码行数:9,代码来源:UnitOfWork.cs

示例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>();
 }
开发者ID:tmchan,项目名称:ncommon,代码行数:22,代码来源:UnitOfWorkScopeTransaction.cs

示例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();
        }
开发者ID:tasluk,项目名称:hibernatingrhinos,代码行数:13,代码来源:UnitOfWork_Fixture.cs

示例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();
        }
开发者ID:beginor,项目名称:practice,代码行数:14,代码来源:UnitOfWork_Fixture.cs

示例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();
        }
开发者ID:realzhaorong,项目名称:cslaptrackerfactory,代码行数:19,代码来源:UnitOfWork_With_Factory_Fixture.cs

示例7: CategoryService

 public CategoryService(IUnitOfWorkFactory factory)
 {
     _unitOfWork = factory.Create();
    _repository = _unitOfWork.Repository<Category>();
 }
开发者ID:devSlike,项目名称:NewTasks,代码行数:5,代码来源:CategoryService.cs

示例8: SubTaskService

 public SubTaskService(IUnitOfWorkFactory factory)
 {
     _unitOfWork = factory.Create();
     _taskRepository = _unitOfWork.Repository<Task>();
     _repository = _unitOfWork.Repository<SubTask>();
 }
开发者ID:devSlike,项目名称:NewTasks,代码行数:6,代码来源:SubTaskService.cs


注:本文中的IUnitOfWorkFactory.Create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。