Finding the Primary Key from a ClassMap<T>
问题 With Fluent NHibernate , I have an arbitrary ClassMap<T> , I want to be able to find out what property (if any) was set as the primary key . Example: public class PersonMap : ClassMap<Person> { public PersonMap() { Id(p => p.StupidPrimaryKeyId).GeneratedBy.Identity().Column("StupidPrimaryKeyId"); } } ... //usage MemberInfo primaryKeyMember = FindPrimaryKey(new PersonMap()); Can anybody tell me what the method body for FindPrimaryKey would have to be in order to return StupidPrimaryKeyId ?