Book Image

Learning NHibernate 4

Book Image

Learning NHibernate 4

Overview of this book

Table of Contents (18 chapters)
Learning NHibernate 4
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Event system


We have learned that entity state in the memory is synchronized to the database either when session is flushed or transaction is committed. All the calls we made to ISession.Save or ISession.Update till that point do not send any changes to the database. Instead, what they do is create an event and push it into the events array maintained by the session. When the session is flushed (explicitly or via committing the transaction), then NHibernate goes through each of the events and executes them one by one. As usual, I am making it easy by giving you a 10,000 feet view of how events work. Exact working of the events is more complex in reality. Intent of this section is not to understand how the events work internally. This section is more about how to listen to NHibernate's internal events and how to be notified so that we can execute our own code in response to a particular action that NHibernate carries out internally. Event listener is the mechanism that we would use for this...