如何在运行时在nhibernate集合映射中查找Key列

时间:2018-11-25 05:40:35

标签: nhibernate nhibernate-mapping

我需要知道nhibernate映射中映射包的Key列名称。 但是我没有在NHibernate.Cfg.Configuration.CollectionMappingsCollection类型的每个项目中找到任何东西。

例如,我们具有以下配置:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Farayan.Web.Portal" namespace="Farayan.Web.Portal.EntityLayer" >
    <class name="ModuleEntity" table="Portal_ModulesTable">
        <id name="Id">
            <generator class="identity"/>
        </id>
        <version name="Version"/>
        <bag name="Properties" table="Portal_ModulePropertiesTable" lazy="false" fetch="subselect">
            *<key column="Module"/>*
            <composite-element class="Farayan.Web.Portal.PropertyValue">
                <property name="Name"/>
                <property name="Value"/>
                <property name="Culture"/>
            </composite-element>
        </bag>
    </class>
</hibernate-mapping>

我想找到列Module的名称(在cfg中用*包围)

但是在下面的代码中:

foreach (Collection collectionMapping in configuration.CollectionMappings) {
    //collectionMapping.Key is null!
}

collectionMapping.Key为空

0 个答案:

没有答案