I am wondering if it is possible to find the run-time column name for the class / component that was mapped to FluentNHibernate after applying all conventions.
For example, given a 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 donβt know how to do it:
var mappings = FluentNHibaernate.CompileMergeAndBuildAllMappings(); var zipCodeColumnName = mappings.FindMappedType<Address>().ColumnName(a => a.Zip) zipCodeColumnName.ShouldBe("ADDRESS_Zip");
Additional clarification
- I'm only interested in the result of applying FluentNHiberante conventions and comparisons. Not in the real SQL generated by NHibernate.
Thanks for the help,
Brian
source share