Nhibernate 在使用 QueryOver 时无法解决属性异常,适用于 QueryAll
我遇到以下问题
基本上我有下面的两个片段:
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
有人知道这是为什么吗? 先感谢您
I have the following problem
Basically I have the 2 snippets below:
var contactAssociation =
session.QueryOver<ContactAssociation>(() => contactAssociationAlias)
.Where(() =>
contactAssociationAlias.Contact.ID == careGiverId &&
contactAssociationAlias.Client.ID == clientKey)
.Where(() =>
contactAssociationAlias.AclRole.RoleName == "Care Giver")
.SingleOrDefault();
and
var contactAssociation = session.Query<ContactAssociation>()
.Where(cr =>
cr.Contact.ID == careGiverId
&& cr.Client.ID == clientKey)
.Where(cr =>
cr.AclRole.RoleName == "Care Giver")
.SingleOrDefault();
the second one works the first one outputs this error:
Message=could not resolve property: AclRole.RoleCode of:
SL.STAdmin.DAL.ContactAssociation
Does anyone know why this is?
Thank you in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在第一个查询中指定联接。第二个查询中的 LINQ 提供程序会自动为您执行此操作。
You need to specify a Join in the first query. The LINQ provider in the second query does it automatically for you.