Hi guys,
Is there some way to queue the "Add" operation in NHibernate, just like Linq to SQL and Entity Framework does?
I want to add an entity to the repository, but I don't want to save it to the database immediately, because the business logic is complex. I want to submit all changes when I call ITransaction.Commit(), just like Entity Framework does. Can I do that?
NOTE: I found that NHibernate will execute an insert command as soon as I call ISession.Save() method, that's not expected.
UPDATE: I try setting the FlushMode to Commit. But it still save the entity immediately, not commit all changes when I call ITransaction.Commit().
UPDATE 2 I found the reason here http://nhforge.org/doc/nh/en/index.html#manipulatingdata-flushing : (An exception is that objects using native ID generation are inserted when they are saved.). So I can only change the Id generator to some thing other than "identity"? No other solutions similar to the solution in EntityFramework?