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


C# ITransaction.Commit方法代码示例

本文整理汇总了C#中ITransaction.Commit方法的典型用法代码示例。如果您正苦于以下问题:C# ITransaction.Commit方法的具体用法?C# ITransaction.Commit怎么用?C# ITransaction.Commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITransaction的用法示例。


在下文中一共展示了ITransaction.Commit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Intercept

        public void Intercept(IInvocation invocation)
        {
            var sessionFactories = NHibernateSessionManager.SessionFactories;
            var method = invocation.Method;
            var isTransactionScoped = method.IsDecoratedBy(typeof(TransactionAttribute));

            if (isTransactionScoped) {
                foreach (var sessionFactory in sessionFactories)
                {
                    var session = sessionFactory.GetSession();

                    _transaction = sessionFactory.GetSession().Transaction.IsActive
                                ? _session.Transaction
                                : _session.BeginTransaction();
                }
                _transaction = _session.Transaction;

                try {
                    invocation.Proceed();

                    _transaction.Commit();
                } catch (Exception) {
                    _transaction.Rollback();

                    throw;
                } finally {
                    _transaction.Dispose();
                }
            }
        }
开发者ID:gofixiao,项目名称:Macsauto-Backup,代码行数:30,代码来源:TransactionInterceptor.cs

示例2: Eval

 public void Eval(ITransaction transaction, bool throwException = true)
 {
     if (IsValid())
     {
         transaction.Commit();
         return;
     }
     transaction.Rollback();
     if (throwException) ThrowValidationException();
 }
开发者ID:mynamespace,项目名称:NHibernate.Extensions,代码行数:10,代码来源:SessionValidator.cs

示例3: InSession

        protected void InSession(Action<ISession> action)
        {
            using (Session = MeSessionFactory.Instance.SessionFactory.OpenSession())
            {
                using (Transaction = Session.BeginTransaction())
                {
                    action(Session);

                    Transaction.Commit();
                }
            }
        }
开发者ID:kovacsrobert,项目名称:ScratchPad,代码行数:12,代码来源:SessionHandlerBaseClass.cs

示例4: Init

        internal void Init(ISession session, ITransaction transaction)
        {
            this.Session = session;
            this.Transaction = transaction;

            //add base data
            Session.SaveOrUpdate(new DataItem { SendDateTime = DateTime.Now.AddDays(-2), Source = "A", Target = "B", Version = 1 });
            Session.SaveOrUpdate(new DataItem { SendDateTime = DateTime.Now, Source = "A", Target = "B", Version = 2 });
            Session.SaveOrUpdate(new DataItem { SendDateTime = DateTime.Now.AddDays(-2), Source = "A", Target = "C", Version = 1 });
            Session.SaveOrUpdate(new DataItem { SendDateTime = DateTime.Now, Source = "A", Target = "C", Version = 2 });
            Session.SaveOrUpdate(new DataItem { SendDateTime = DateTime.Now, Source = "A", Target = "D", Version = 1 });

            Transaction.Commit();
        }
开发者ID:Tviljan,项目名称:NHibernate-GROUP-BY-Problem,代码行数:14,代码来源:App.cs

示例5: save

 public bool save(Rule rule)
 {
     trans = session.BeginTransaction();
     try
     {
         session.Save(rule);
         trans.Commit();
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
开发者ID:ryanyau,项目名称:mobile,代码行数:14,代码来源:RuleDao.cs

示例6: saveRecord

        public void saveRecord(CallRecord callRecord)
        {
            trans = session.BeginTransaction();

            try
            {
                session.Save(callRecord);
                trans.Commit();
            }
            catch (Exception)
            {
                throw new Exception();
            }
        }
开发者ID:ryanyau,项目名称:mobile,代码行数:14,代码来源:CallRecordDao.cs

示例7: save

 public bool save(Account account)
 {
     trans = session.BeginTransaction();
     try
     {
         session.Save(account);
         trans.Commit();
         return true;
     }
     catch (Exception)
     {
         trans.Rollback();
         return false;
     }
 }
开发者ID:ryanyau,项目名称:mobile,代码行数:15,代码来源:AccountDao.cs

示例8: save

 public bool save(Customer customer)
 {
     trans = session.BeginTransaction();
     try
     {
         session.Save(customer);
         trans.Commit();
         return true;
     }
     catch (Exception)
     {
         trans.Rollback();
         return false;
     }
 }
开发者ID:ryanyau,项目名称:mobile,代码行数:15,代码来源:CustomerDao.cs

示例9: OnSetUp

        protected override void OnSetUp()
        {
            base.OnSetUp();

            a = new Author();
            a.Name = "Voltaire";
            a2 = new Author();
            a2.Name = "Victor Hugo";
            a3 = new Author();
            a3.Name = "Moliere";
            a4 = new Author();
            a4.Name = "Proust";

            o = new Order();
            o.OrderNumber = "ACVBNM";

            o2 = new Order();
            o2.OrderNumber = "ZERTYD";

            p1 = new Product();
            p1.Name = "Candide";
            p1.Authors.Add(a);
            p1.Authors.Add(a2); //be creative

            p2 = new Product();
            p2.Name = "Le malade imaginaire";
            p2.Authors.Add(a3);
            p2.Orders.Add("Emmanuel", o);
            p2.Orders.Add("Gavin", o2);

            s = OpenSession();
            tx = s.BeginTransaction();
            s.Persist(a);
            s.Persist(a2);
            s.Persist(a3);
            s.Persist(a4);
            s.Persist(o);
            s.Persist(o2);
            s.Persist(p1);
            s.Persist(p2);
            tx.Commit();

            tx = s.BeginTransaction();

            s.Clear();
        }
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:46,代码来源:IndexedEmbeddedAndCollections.cs

示例10: checkBalance

 //重载checkBalance方法
 public bool checkBalance(Int64 num, float least, float mus)
 {
     trans = session.BeginTransaction();
     try
     {
         Mobile mobile = session.CreateQuery("from Mobile as c where c.Mobilenumber='" + num + "'").UniqueResult<Mobile>();
         mobile.Balance = mobile.Balance - mus;
         session.Update(mobile);
         trans.Commit();
         if (mobile.Balance >= least) return true;
         else return false;
     }
     catch (Exception)
     {
         throw new Exception();
     }
 }
开发者ID:ryanyau,项目名称:mobile,代码行数:18,代码来源:MobileDao.cs

示例11: saveMessage

 public bool saveMessage(string message)
 {
     trans = session.BeginTransaction();
     try
     {
         Complain m = new Complain();
         m.Message = message;
         m.Dtime=DateTime.Now;
         session.Save(m);
         trans.Commit();
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
开发者ID:kutang,项目名称:mobile,代码行数:17,代码来源:ComplainDao.cs

示例12: addGrade

 public bool addGrade(Int32 level)
 {
     trans = session.BeginTransaction();
     try
     {
         Grade g = new Grade();
         g.Dtime = DateTime.Now;
         g.Level = level;
         session.Save(g);
         trans.Commit();
         return true;
     }
     catch (Exception)
     {
         throw new Exception();
     }
 }
开发者ID:kutang,项目名称:mobile,代码行数:17,代码来源:GradeDao.cs

示例13: changeState

 public void changeState(Int64 num)
 {
     trans = session.BeginTransaction();
     try
     {
         var hql = @"from Mobile p
                     where p.Mobilenumber=:phoneNumber";
         Mobile p = session.CreateQuery(hql)
             .SetString("phoneNumber", num.ToString())
             .UniqueResult<Mobile>();
         p.State = "stop";
         trans.Commit();//提交
     }
     catch (Exception)
     {
         throw new Exception();
     }
 }
开发者ID:kutang,项目名称:mobile,代码行数:18,代码来源:MobileDao.cs

示例14: BuyNewComputer

        public bool BuyNewComputer(Computer c)
        {
            bool bReturn = true;
            try
            {
                session = sessionFactory.OpenSession();
                tx = session.BeginTransaction();

                session.Save(c);

                tx.Commit();
            }
            catch(Exception ex)
            {
                bReturn = false;
            }
            finally
            {
                session.Flush();
                session.Disconnect();
            }
            return bReturn;
        }
开发者ID:hungtrinh81,项目名称:leonworkshop,代码行数:23,代码来源:DataAccesser.cs

示例15:

 private static void \u003CInjectedAspect_Dependency_ShouldBeCommited\u003Eb__1(ITransaction m)
 {
   m.Commit();
 }
开发者ID:akimboyko,项目名称:AOP.Hydra,代码行数:4,代码来源:InjectedAspectTests+—+decompiled.cs


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