该语句正在使用我试图摆脱的 foreach:
CBTAppointmentDto app = null;
ModifyAppointmentRequest alias = null;
Domain.PearsonVue.TestCenter center = null;
Exam exam = null;
var result = Session.QueryOver(() => alias)
.Where(x => x.Candidate.Id == candidateId)
.Where(x => x.EventType == "ApptCreated")
.JoinAlias(x => x.Exams, () => exam)
.JoinAlias(() => alias.TestCenter, () => center)
.SelectList(list => list
.Select(() => exam.ExamName).WithAlias(() => app.TestName)
.Select(() => exam.ExamSeriesCode)
.WithAlias(() => app.ExamSeriesCode)
.Select(() => alias.AppointmentStartTime)
.WithAlias(() => app.TestDate)
.Select(() => center.TestCenterName)
.WithAlias(() => app.TestCenterName))
.TransformUsing(Transformers.AliasToBean<CBTAppointmentDto>())
.List<CBTAppointmentDto>().ToList();
foreach (var cbtAppointmentDto in result)
{
var session = Session.QueryOver<TestSession>()
.Where(x => x.SessionName == cbtAppointmentDto.ExamSeriesCode)
.SingleOrDefault();
if (session == null) continue;
cbtAppointmentDto.TestStartDate = session.TestsStartDate;
cbtAppointmentDto.TestEndDate = session.TestsEndDate;
}
return result;
有没有办法只用一个QueryOver
声明来做到这一点?
有什么建议么 ?