예제 #1
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (!Nested)
            {
                if (!_completed)
                {
                    try
                    {
                        if (_readOnly)
                        {
                            ScopeData.Commit();
                        }
                        else
                        {
                            ScopeData.Rollback();
                        }
                    }
                    catch (Exception e)
                    {
                        _exceptionHandler?.HandleException(e);
                    }
                }

                _completed = true;
                ScopeData.Dispose();
            }
        }
예제 #2
0
        public int SaveChanges()
        {
            if (Disposed)
            {
                throw new ObjectDisposedException("SessionScope");
            }

            if (_completed)
            {
                throw new InvalidOperationException("Not possible to save changes more than once");
            }

            var c = 0;

            if (!Nested)
            {
                c = ScopeData.Commit();
            }

            _completed = true;
            return(c);
        }