Nhibernate在使用QueryOver时无法解决属性异常,可以在QueryAll上使用

|| 我有以下问题 基本上我有以下2个摘要:
var contactAssociation =
    session.QueryOver<ContactAssociation>(() => contactAssociationAlias)
        .Where(() =>
             contactAssociationAlias.Contact.ID == careGiverId &&
             contactAssociationAlias.Client.ID == clientKey)
        .Where(() =>
             contactAssociationAlias.AclRole.RoleName == \"Care Giver\")
        .SingleOrDefault();
var contactAssociation = session.Query<ContactAssociation>()
    .Where(cr =>
        cr.Contact.ID == careGiverId
        && cr.Client.ID == clientKey)
    .Where(cr =>
        cr.AclRole.RoleName == \"Care Giver\")
    .SingleOrDefault();
第二个工作,第一个输出此错误:
Message=could not resolve property: AclRole.RoleCode of:
SL.STAdmin.DAL.ContactAssociation
有人知道为什么是这样吗? 先感谢您     
已邀请:
        您需要在第一个查询中指定一个联接。第二个查询中的LINQ提供程序会自动为您执行此操作。
session.QueryOver<ContactAssociation>(() => contactAssociationAlias)
   .Where(() =>
       contactAssociationAlias.Contact.ID == careGiverId &&
       contactAssociationAlias.Client.ID == clientKey)
   .JoinQueryOver(() => contactAssociationAlias.AclRole)
       .Where(a => a.RoleName == \"Care Giver\")
   .SingleOrDefault();
    

要回复问题请先登录注册