我有一个 NHibernate 映射文件,我想将其转换为流利的。我被这个特殊情况所困扰:
<many-to-one name="LastChildRevision" update="false" not-found="ignore" access="readonly" fetch="join">
<formula>(SELECT TOP(1) CHILD_REVISION.CHILD_REVISION_ID FROM CHILD_REVISION WHERE CHILD_REVISION.PARENT_ID = PARENT_ID ORDER BY CHILD_REVISION.REVISION_NUMBER DESC)</formula>
</many-to-one>
我的班级有:
public virtual IList<ChildRevision> ChildRevisions { get; set; }
public virtual ChildRevision LastChildRevision
{
get
{
return this.ChildRevisions.OrderBy(o => o.RevisionNumber).LastOrDefault();
}
}
我怎样才能把它翻译成 Fluent NHibernate?当我尝试这个时:
References(x => x.LastChildRevision)
.Formula("(SELECT TOP(1) CHILD_REVISION.CHILD_REVISION_ID FROM CHILD_REVISION WHERE CHILD_REVISION.PARENT_ID = PARENT_ID ORDER BY CHILD_REVISION.REVISION_NUMBER DESC)")
.Access
.ReadOnly()
.Fetch
.Join();
我明白了:
Invalid column name 'LastChildRevision_id'.
谢谢!