Exemple #1
0
        IUnitOfWork CreateUowNothing(bool isNotSupported)
        {
            var uow     = new UnitOfWorkNothing(Orm);
            var uowInfo = new UowInfo(uow, UowInfo.UowType.Nothing, isNotSupported);

            uow.OnDispose = () => _allUows.Remove(uowInfo);
            _allUows.Add(uowInfo);
            SetAllRepositoryUow();
            return(uow);
        }
Exemple #2
0
        IUnitOfWork FindedUowCreateVirtual()
        {
            var isNotSupported = _allUows.LastOrDefault()?.IsNotSupported ?? false;

            if (isNotSupported == false)
            {
                for (var a = _rawUows.Count - 1; a >= 0; a--)
                {
                    if (_rawUows[a].Uow.GetOrBeginTransaction(false) != null)
                    {
                        var uow     = new UnitOfWorkVirtual(_rawUows[a].Uow);
                        var uowInfo = new UowInfo(uow, UowInfo.UowType.Virtual, isNotSupported);
                        uow.OnDispose = () => _allUows.Remove(uowInfo);
                        _allUows.Add(uowInfo);
                        SetAllRepositoryUow();
                        return(uow);
                    }
                }
            }
            return(null);
        }
Exemple #3
0
        IUnitOfWork CreateUow(IsolationLevel?isolationLevel)
        {
            var uow     = new UnitOfWorkOrginal(new UnitOfWork(Orm));
            var uowInfo = new UowInfo(uow, UowInfo.UowType.Orginal, false);

            if (isolationLevel != null)
            {
                uow.IsolationLevel = isolationLevel.Value;
            }
            try { uow.GetOrBeginTransaction(); }
            catch { uow.Dispose(); throw; }

            uow.OnDispose = () =>
            {
                _rawUows.Remove(uowInfo);
                _allUows.Remove(uowInfo);
                SetAllRepositoryUow();
            };
            _rawUows.Add(uowInfo);
            _allUows.Add(uowInfo);
            SetAllRepositoryUow();
            return(uow);
        }