0
我有桌面應用程序和Web應用程序引用的常見dll。其中一種方法創建3個對象,並將它們插入到事務中的DB中。NHibernate事務在Postgres上無法正常工作
但是,當我從Web應用程序和桌面應用程序同時調用此方法時,不會插入對象3by3 ...它們的順序是混合的(1從桌面應用程序,接着是1從Web應用程序等)。
我的代碼是否正常?是否有關於映射或nhibernate cfg的問題? 非常感謝您提前。
Notifications not = new Notifications();
not.Notes = applicationName;
not.GeneratedTime = DateTime.Now;
using (var session = SessionManager.OpenSession())
using (var transaction = session.BeginTransaction())
{
// do what you need to do with the session
session.Save(not);
not = new Notifications();
not.Notes = applicationName;
not.GeneratedTime = DateTime.Now;
session.Save(not);
not = new Notifications();
not.Notes = applicationName;
not.GeneratedTime = DateTime.Now;
// do what you need to do with the session
session.Save(not);
transaction.Commit();
}
行的關係數據庫是不*** ***「排序」。它們的存儲順序完全不相關。只要確保在檢索數據時應用了合適的ORDER BY。這可以使用例如一個時間戳列,用於存儲行插入的時間。 –