使用QueryOver时,Nhibernate无法解析属性exception,适用于QueryAll
我有以下问题
基本上我有以下两个片段:
var contactAssociation = session.QueryOver(() => contactAssociationAlias) .Where(() => contactAssociationAlias.Contact.ID == careGiverId && contactAssociationAlias.Client.ID == clientKey) .Where(() => contactAssociationAlias.AclRole.RoleName == "Care Giver") .SingleOrDefault();
和
var contactAssociation = session.Query() .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
有人知道为什么吗? 先感谢您
您需要在第一个查询中指定Join。 第二个查询中的LINQ提供程序会自动为您执行此操作。
上述就是C#学习教程:使用QueryOver时,Nhibernate无法解析属性exception,适用于QueryAll分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
session.QueryOver(() => contactAssociationAlias) .Where(() => contactAssociationAlias.Contact.ID == careGiverId && contactAssociationAlias.Client.ID == clientKey) .JoinQueryOver(() => contactAssociationAlias.AclRole) .Where(a => a.RoleName == "Care Giver") .SingleOrDefault();
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/988195.html