NHibernate: How to get mapped values?
nhibernate
Solution
You can access the database field name through `NHibernate.Cfg.Configuration`:
// cfg is NHibernate.Cfg.Configuration
// You will have to provide the complete namespace for Customer
var persistentClass = cfg.GetClassMapping(typeof(Customer));
var property = persistentClass.GetProperty("FirstName");
var columnIterator = property.ColumnIterator;
The `ColumnIterator` property returns `IEnumerable<NHibernate.Mapping.ISelectable>`. In almost all cases properties are mapped to a single column so the column name can be found using `property.ColumnInterator.ElementAt(0).Text`.
Problem
Suppose I have a class Customer that is mapped to the database and everything is a-ok. Now suppose that I want to retrieve - in my application - the column name that NH knows Customer.FirstName maps to. How would I do this?