开发者

NHibernate - dirty ISession not updating

开发者 https://www.devze.com 2023-01-06 22:02 出处:网络
When the save button is clicked, the following code is run [PersistenceSession is a property returning an ISession instance]:

When the save button is clicked, the following code is run [PersistenceSession is a property returning an ISession instance]:

_storedWill = PersistenceSession.Load<StoredWill&g开发者_JAVA技巧t;(_storedWillId);
_storedWill.WillReference = txtWillReference.Text;
_storedWill.IntroducerReference = txtIntroducerReference.Text;
//A stack of other properties of the _storedWill object assigned
PersistenceSession.SaveOrUpdate(_storedWill);

A breakpoint set on the final line reveals that PersistenceSession.IsDirty() is true.

However, no update SQL is generated. Can anyone think why?

Thanks

David


You need to Flush the session to have the updates sent to the database. SaveOrUpdate will not send anything to the database unless you are persisting a newly-created entity, whose ID values are database generated. Since you are just updating, all this does is ensures that the _storedWill entity is associated with the ISession returned by the PersistenceSession property.

0

精彩评论

暂无评论...
验证码 换一张
取 消