Archive for the ‘nHiberante’ Tag

nHibernate: Component MetaData

Adding some auditing events to nHibernate through its new event system. A particular requirement of the auditing implementation needs the component types be unwrapped and audited along with the parent object. As a first entry into the nHibernate metadata, I found that calling GetClassMetaData() for a component type would return a null reference, since the component is not an entity.

Instead, if you use the Property’s IType for the component, you can cast it down to a NHibernate.Type.ComponentType. This will then allow you to access the Propery names and values for a component object.

Fun stuff.

Advertisements