Thanks Gunnar, in fact the reason I was getting the entity returned was a race condition (my program being multi threaded), where in fact Session.Query was being called *before* Delete was being called.
I believe the answer to the question is 'no' - Delete (without a flush) ensures subsequent calls to the Session do not return the entity - I imagine this is because Delete updates in memory Session only, and Flush synchronises Session with the database. You can try a small test yourself to show this is the case. On Wednesday, February 4, 2015 at 10:15:08 PM UTC, Gunnar Liljas wrote: > > Yes, it is expected. Use Flushmode.Commit or call session.flush manually. > > /g > > — > Sent from Mailbox <https://www.dropbox.com/mailbox> > > > On Wed, Feb 4, 2015 at 9:45 PM, sturdytree <[email protected] > <javascript:>> wrote: > >> >> If I have the following, with a FlushMode of Never: >> >> using (ITransaction txn = Session.BeginTransaction) >> { >> Session.Delete(entity); >> txn.Commit >> } >> >> is it expected behaviour that subsequently calling Session.Query<T> to >> load all entities will include the above entity, where Flush is called >> after Session.Query? >> >> The reason I call Flush later is that I run Session on a separate thread >> so database calls take place behind the scenses and don't slow the >> application. >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "nhusers" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> Visit this group at http://groups.google.com/group/nhusers. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/nhusers. For more options, visit https://groups.google.com/d/optout.
