1
NHibernateSessionManager.Instance.GetSessionFrom(SessionFactoryConfigPath).Flush();
後不沖水的會議上,我得到發生異常
null id in FoodOrder.Core.Entities.Articles entry (don't flush the Session after an exception occurs)
我可以只使用嘗試捕捉和session.Close或什麼是更好的在這個例子呢?
例如
public void CommitChanges()
{
if (NHibernateSessionManager.Instance.HasOpenTransactionOn(SessionFactoryConfigPath))
{
NHibernateSessionManager.Instance.CommitTransactionOn(SessionFactoryConfigPath);
}
else
{
try
{
// If there's no transaction, just flush the changes
NHibernateSessionManager.Instance.GetSessionFrom(SessionFactoryConfigPath).Flush();
}
finally
{
NHibernateSessionManager.Instance.GetSessionFrom(SessionFactoryConfigPath).Close();
}
}
}
什麼是不沖洗會議的影響?如果前一個會話沒有被刷新,下一個「保存」調用會發生什麼? – ganders 2014-09-22 15:31:33