Is there anything in nhibernate that lets me get the list of mapped classes that refer some other class?
Is there some feature in n开发者_StackOverflow社区hibernate that goes through all the mapping files and can get me a list of class names that refer to (many to one) another class?
It would be quite handy, if I could do this, then I could run some queries to tell the user exactly why they're not allowed to delete certain values, instead of throwing a gross looking foreign key violation message...
Thanks
Isaac
An extremely simplified approach:
foreach (var classMetadata in sessionFactory.GetAllClassMetadata())
foreach (propertyType in classMetadata.PropertyTypes)
if (propertyType.IsEntityType)
//this is a foreign key
Then you have sessionFactory.GetAllCollectionMetadata()
, etc.
This should get you started.
精彩评论