NHibernate has a lot of proxying going on. Have you investigated if you can hook up this with a custom proxy generator?
/Oskar 2016-03-08 10:52 GMT+00:00 Felix Berlakovich <fberlakov...@gmail.com>: > Some additions: > * a colleague pointed out that the stuff I am talking about are actually > proxies and not decorators which is absolutely correct. However, this is > just a semantic difference. > * I found a way to forcefully change the collection in PreUpdateCollection > by casting the incoming collection to IList and change its elements. > However, this solution seems dangerous to me and furthermore the > eventhandler is called for each object changed in the collection. The > collection would be converted several times. > > On Monday, March 7, 2016 at 3:19:08 PM UTC+1, Felix Berlakovich wrote: >> >> I am using decorators to decorate my entities. For example, I have a >> security decorator that hides values of entity properties not visible to >> the calling user. The decorators are put in place by special repositories >> decorating my common repositories. All this works as expected. >> >> However, this approach leads to a problem when objects are persisted. For >> example, due to the mapping NHibernate expects an InventoryItem entity, but >> will receive a SecurityInventoryItem (the decorated entity). As a result an >> exception stating "Object does not match target type" is thrown. This is >> totally understandable, however mapping the common interface IInventoryItem >> is not an option either because the decorators would hide valuable >> information from NHibernate. >> >> Is there any hook in NHibernate that is called for each entity to be >> saved / updated that allows me to unwrap the entity (i.e transform entities >> before they are persisted)? I successfuly implemented the unwrapping for >> the save case with an IPreInsertEventListener, however I cannot find a way >> to do it for the update case. >> >> Thanks! >> > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to nhusers+unsubscr...@googlegroups.com. > To post to this group, send email to nhusers@googlegroups.com. > Visit this group at https://groups.google.com/group/nhusers. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+unsubscr...@googlegroups.com. To post to this group, send email to nhusers@googlegroups.com. Visit this group at https://groups.google.com/group/nhusers. For more options, visit https://groups.google.com/d/optout.