我有以下代码:
using (var session = SessionFactory.OpenSession())
{
var entity = session.Get<Entity>(id);
entity.Property1 = "new value";
using (var tx = session.BeginTransaction())
{
entity.Property2 = "new value";
tx.Commit();
}
}
而现在,我很困惑,什么时候tx.Commit()
,什么将提交给数据库?是只有Property2
(在事务范围内)将被提交,还是两者都Property1
将Property2
被提交?