单击保存按钮时,以下代码为run PersistenceSession是一个返回ISession实例的属性
_storedWill = PersistenceSession.Load<StoredWill>(_storedWillId);
_storedWill.WillReference = txtWillReference.Text;
_storedWill.IntroducerReference = txtIntroducerReference.Text;
//A stack of other properties of the _storedWill object assigned
PersistenceSession.SaveOrUpdate(_storedWill);在最后一行设置的断点表明PersistenceSession.IsDirty()为真。
但是,不会生成更新SQL。有人知道为什么吗?
谢谢
大卫
发布于 2010-07-14 17:56:21
您需要对会话执行Flush操作,以便将更新发送到数据库。SaveOrUpdate不会向数据库发送任何内容,除非您持久化一个新创建的实体,该实体的ID值是数据库生成的。由于您只是在更新,因此所有这些操作都是为了确保_storedWill实体与PersistenceSession属性返回的ISession相关联。
https://stackoverflow.com/questions/3245013
复制相似问题