How to manually override the OnLoad property in NHibernate?

Is it possible to manually modify an object when it is loaded from a database using NHibernate. Is there an OnLoad event listener that we can override or inherit from which will allow us to manually set the entity.

For clarity, we want to assign a custom object when the property is null . We successfully do the opposite when we save the database, but will rather implement the logic in the NHibernate listener, rather than in the "Getter" property.

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

+4
source share
1 answer

You can implement IPostLoadEventListener . This is just one method:

 void OnPostLoad(PostLoadEvent @event) 

I think this is exactly what you want.

+3
source

Source: https://habr.com/ru/post/1341917/


All Articles