更新时间:2022-06-22 19:44:00
您可以使用NHibernate元数据API查找映射的属性,并使用反射查找所有属性.
You could use the NHibernate meta-data API to find the mapped properties, and reflection to find all the properties.
修改,不,没有其他方法可以列出包括ID在内的所有属性.使用起来并不难:
Edit No, there isn't any other way list all the properties including the id. It isn't that hard to use:
foreach (PropertyInfo info in infos)
{
if (meta.PropertyNames.Contains(info.Name) || info.Name = meta.IdentifierPropertyName)
{
Console.WriteLine("{0} is mapped!", info.Name);
}
else
{
Console.WriteLine("{0} is not mapped!", info.Name);
}
}