views:

13

answers:

1

Hi all

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

_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);

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

+1  A: 

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.

David M
Oh, it's you again, with your trombone! How are tricks? :)Or you can create an ITransaction and commit it. I'm not sure of the pluses/minuses of each approach.
David
:) Fine thanks. Not sure if the ITransaction approach will try to use a distributed transaction, which of course may be problematic in certain environments due to possible firewall port requirements.
David M