问题
How do I do a equals condition in an outer join in Nhibernate/QueryOver/ICriteria?
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 }))
// ^^^^
(I am reusing an earlier query question.)
回答1:
We can use the .Where()
part of 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 ))
来源:https://stackoverflow.com/questions/40016552/equals-conditions-in-outer-joins-with-nhibernate-icriteria-queryover-query