开发者

nhibernate SaveOrUpdate - easily determine which of the operations will be performed

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 betwee开发者_运维百科n 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?


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."

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜