This query:
var appointments = from a in db.Appointment
let Mp = (from mpAt in db.Attendee
where mpAt.FkAppointment == a.PkAppointment &&
mpAt.FkAccount == pkMp
select new
{
mpAt.FkAccount,
mpAt.FkAppointment,
mpAt.AppointmentLength,
mpAt.AppointmentStartTimeOffset
}).First()
let Pa = (from paAt in db.Attendee
join pa in db.Person on paAt.FkAccount equals pa.PfkPerson
where paAt.FkAppointment == a.PkAppointment
select new
{
paAt.FkAppointment,
AccountType = paAt.Account.FkAccountType,
Name = pa.Title.Name + " " +paAt.Account.Name,
NewPerson = pa.NewPerson
}).FirstOrDefault()
where
a.Start >= fromTime &&
a.Start < toTime &&
a.Status == false &&
a.FkSite == site
select new AppointmentDetails
(
a.PkAppointment,
a.FkLocation,
a.Arrived,
a.Noshow,
a.ScheduleServicesCache,
Mp.AppointmentLength,
Mp.AppointmentStartTimeOffset,
Pa.Name,
Pa.NewPerson,
a.Start,
a.Finish,
a.Subject
);
Is throwing this error: "A nested query in the projection has no correlation filter to tie its set to the containing parent row. Please add a correlation filter to the where clause of this query to tie the nested query to the parent."
A bit of background:
Tables:
Account
Person
Mp
Appointment
Attendee
A Person is a type of Account. An Mp (Medical Person) is a type of Account. Each Appointment can have several Attendees. An Attendee could be a Person or an Mp.
I am looking to get all the appointments for a particular Medical Person between the dates provided, and on the site provided. I also need to know the patient (Person) involved in that appointment. There may be none (meeting).
The error appears to infer that there's no correlation between the query and subquery(s). Surely it correlates if I return zero or one result for each subquery, and it's matched to the primary-key of the appointment table? Or am I missing something?
I'm running 2.6 released May 15th 2009.
Thanks
Paul