本文介绍了使用NHibernate ICriteria/QueryOver查询等于外部联接中的条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Nhibernate/QueryOver/ICriteria中的外部联接中实现等于条件?
How do I do a equals condition in an outer join in Nhibernate/QueryOver/ICriteria?
我发现下面将surveyRequest.Survey.Id
与surveyID
进行比较的唯一方法是与IsIn
.
The only way I have found to compare surveyRequest.Survey.Id
with surveyID
below is with IsIn
.
SystemUser systemUser= null;
SurveyRequests surveyRequest = null;
var query = Session.QueryOver<SystemUser>(() => systemUser)
.Left.JoinAlias(
() => systemUser.SurveyRequests,
() => surveyRequest,
Restrictions.On(()=>surveyRequest.Survey.Id).IsIn(new object []{surveyID }))
// ^^^^
(我正在重用以前的查询问题.)
推荐答案
我们可以使用Restrictions
var query = Session.QueryOver<SystemUser>(() => systemUser)
.Left.JoinAlias(
() => systemUser.SurveyRequests,
() => surveyRequest,
//Restrictions.On(()=>surveyRequest.Survey.Id).IsIn(new object []{surveyID }))
Restrictions.Where(()=>surveyRequest.Survey.Id == surveyID ))
这篇关于使用NHibernate ICriteria/QueryOver查询等于外部联接中的条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!