Reputation: 14039
I am new to nhibernate. I am developing a small c# application, using the repository pattern. In my repository I've implemented a simple hook to detect when the entity is being saved. I call the entity's event handler to perform whatever operation the entity might need.
My problem is, that I also use the SaveOrUpdate method. Since I merely need to call the event handler on just save operations, I cannot differentiate between the save or the update in the SaveOrUpdate call.
So, in short, Is there any simple way to figure what operations will be performed - will it be a save, or an update?
Upvotes: 1
Views: 1484
Reputation: 13096
nHibernate will call a Save method if the ID of the entity is not set, otherwise will call Update method.
Look here:
SaveOrUpdate Vs Update and Save in NHibernate
"SaveOrUpdate() looks at the identifier and decides what is necessary in the above."
Upvotes: 6