示例#1
0
        public override ResponseMessage <int> Commit(IsolationLevel?level = null, int retry = 1, bool lockd = false)
        {
            var transaction = this._sessionFactory.Current.BeginTransaction(level ?? this._sessionFactory._IsolationLevel);

            try
            {
                this.NewEntityList.Each(e => this._sessionFactory.Current.Save(e));
                this.ModifyEntityList.Each(e => this._sessionFactory.Current.Update(e));
                this.DeleteEntityList.Each(e => this._sessionFactory.Current.Delete(e));
                transaction.Commit();
                this.ClearAllEntity();
                return(ResponseMessage <int> .CreateSuccess(1, message : "ok"));
            }
            catch (Exception ex)
            {
                if (transaction.IsActive)
                {
                    transaction.Rollback();
                }
                this._sessionFactory.Current.Clear();
                return(ResponseMessage <int> .CreateFail(-1, lastErrorMessage : ex.ToString()));
            }
        }