如何在Nhibernate / QueryOver / ICriteria的外部联接中执行等于条件?
我发现将surveyRequest.Survey.Id
与surveyID
进行比较的唯一方法是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 }))
// ^^^^
(我正在重复使用之前的query question。)
答案 0 :(得分:3)
我们可以使用.Where()
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 ))