Alex Burtsev
Alex Burtsev

Reputation: 12668

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.

Upvotes: 4

Views: 2994

Answers (2)

GregorMohorko
GregorMohorko

Reputation: 2857

You can get it using the NHibernate.Cfg.Configuration.GetClassMapping which I found is more detailed than the NHibernate.ISessionFactory.GetClassMetadata.

http://www.nudoq.org/#!/Packages/NHibernate/NHibernate/Configuration/M/GetClassMapping

Upvotes: 2

Andrew Skirrow
Andrew Skirrow

Reputation: 3451

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

Upvotes: 5

Related Questions