I am wondering if it is possible to find the run-time column name for a class/component that has been mapped with FluentNHibernate after all conventions have been applied.
For example, given the simple model:
public class Address{
public string Street {get; set;}
public string Zip {get; set;}
}
public class AddressMap : ComponentMap<Address>{
Map( x => x.Street );
Map( x => x.Zip );
}
public class PersonMap : ClassMap<Person>
{
public PersonMap(){
Id( x => x.Id );
Map( x=> x.Ssn );
Map( x=> x.Name );
Component( x => x.Address )
.ColumnPrefix("ADDRESS_");
}
}
public class ClassConvention : IClassConvention
{
public void Apply( IClassInstance instance )
{
instance.Table( "tbl" + instance.EntityType.Name );
}
}
Table Name: tblPerson
Id Name Ssn ADDRESS_Street ADDRESS_Zip
-----------------------------------------------------------
1 Brian 11223344 123 Example St. 12345
What I'm looking for and what I am not sure how to do is the following:
var mappings = FluentNHibaernate.CompileMergeAndBuildAllMappings();
var zipCodeColumnName = mappings.FindMappedType<Address>().ColumnName(a => a.Zip)
zipCodeColumnName.ShouldBe("ADDRESS_Zip");
// Here I'm interested in the run-time & final column name with the
// prefix applied from the PersonMap class.
var personTableName = mappings.FindMappedType<Person>().TableName;
personTableName.ShouldBe("tblPerson");
// I'm interested in the final table name after the ClassConvention
// modified the table name.
Additional Clarification
- I'm only interested in the result of FluentNHiberante's application of the conventions and mappings. Not in the actual SQL that is generated by NHibernate.
Thanks for the help,
Brian