本文整理汇总了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();
}
}
}
示例2: Eval
public void Eval(ITransaction transaction, bool throwException = true)
{
if (IsValid())
{
transaction.Commit();
return;
}
transaction.Rollback();
if (throwException) ThrowValidationException();
}
示例3: InSession
protected void InSession(Action<ISession> action)
{
using (Session = MeSessionFactory.Instance.SessionFactory.OpenSession())
{
using (Transaction = Session.BeginTransaction())
{
action(Session);
Transaction.Commit();
}
}
}
示例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();
}
示例5: save
public bool save(Rule rule)
{
trans = session.BeginTransaction();
try
{
session.Save(rule);
trans.Commit();
return true;
}
catch (Exception)
{
return false;
}
}
示例6: saveRecord
public void saveRecord(CallRecord callRecord)
{
trans = session.BeginTransaction();
try
{
session.Save(callRecord);
trans.Commit();
}
catch (Exception)
{
throw new Exception();
}
}
示例7: save
public bool save(Account account)
{
trans = session.BeginTransaction();
try
{
session.Save(account);
trans.Commit();
return true;
}
catch (Exception)
{
trans.Rollback();
return false;
}
}
示例8: save
public bool save(Customer customer)
{
trans = session.BeginTransaction();
try
{
session.Save(customer);
trans.Commit();
return true;
}
catch (Exception)
{
trans.Rollback();
return false;
}
}
示例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();
}
示例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();
}
}
示例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;
}
}
示例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();
}
}
示例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();
}
}
示例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;
}
示例15:
private static void \u003CInjectedAspect_Dependency_ShouldBeCommited\u003Eb__1(ITransaction m)
{
m.Commit();
}