Search code examples
c#nhibernatefluent-nhibernatenhibernate-mapping

How to get class mapping information at runtime in Nhibernate?


Where does NHibernate store mapping information at runtime and how to access it? I need to get association properties (complex properties) for a given mapped class at runtime. And i can't rely on reading hbm files because, mapping can be done in fluent nhibernate.


Solution

  • Yes. You can use ISessionFactory.GetClassMetadata to get a metadata object for each persistant type.

    http://www.nudoq.org/#!/Packages/NHibernate/NHibernate/ISessionFactory/M/GetClassMetadata