有这样的映射文件:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="NHibernate.Test"
namespace="NHibernate.Test.NHSpecificTest.CompositeElement">
<class name="Parent" table="Parents">
<id name="ParentId">
<generator class="hilo" />
</id>
<list name="Children" table="Children" inverse="true" cascade="all,delete-orphan">
<key column="ParentId" />
<list-index column="Position" />
<composite-element class="Child">
<parent name="ParentLink"></parent>
</composite-element>
</list>
</class>
</hibernate-mapping>
使用此类实体
public class Parent
{
public virtual int ParentId { get; set; }
public virtual IList<Child> Children { get; set; }
}
public class Child
{
public virtual Parent ParentLink { get; set; }
}
我无法执行以下查询:
(from p in session.Query<Parent>().SelectMany(x => x.Children)
select p.ParentLink.ParentId).ToList();
失败,异常Hibernate.QueryException : could not resolve property: ParentLink of: component[]