开发者

How to manually override property OnLoad method in NHibernate?

开发者 https://www.devze.com 2023-02-14 10:29 出处:网络
Is it possible to manually change an entity when it\'s loaded from the database by NHibernate. Is there a开发者_如何学Pythonn OnLoad event listener which we can override or inherit from which will all

Is it possible to manually change an entity when it's loaded from the database by NHibernate. Is there a开发者_如何学Pythonn OnLoad event listener which we can override or inherit from which will allow us to manually set an entity.

For clarity, we wish to assign a custom entity when the property is null. We are successfully doing the opposite when we persist to the database however would rather implement the logic in an NHibernate listener rather than in the property "Getter".

Please note we do not want to use IInterceptors as we are using the latest version of NHibernate.


You can implement IPostLoadEventListener. It's just one method:

void OnPostLoad(PostLoadEvent @event)

Which I think is exactly what you want.

0

精彩评论

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