Hello,
I'm pretty new still at C# so I might be doing something stupid, but I've spent some time looking at this and still can't see what the problem is.
Here are some code snippets:
double work = 0;
ProjectRepository pr = new ProjectRepository();
IQueryable<CalendarDetail> cds;
// Find matching day of week
// Then for that day, cycle through all working times
// Return list of working times in day
cds = pr.GetCalDetails(calendarID, startTime.DayOfWeek.GetHashCode());
foreach (CalendarDetail cd in cds)
{
DateTime wts = startTime.Date + cd.WorkingTimeStart.Value.TimeOfDay;
DateTime wtf = startTime.Date + cd.WorkingTimeFinish.Value.TimeOfDay;
//more code here....
if ((cds.Last().CalendarDetailID == cd.CalendarDetailID) && (finishTime > wtf))
work += Work(startTime.Date.AddDays(1), finishTime, calendarID);
}
The error is being thrown run-time due to my use of the cds.Last() method call. However, cds has been declared and is being used as an IQueryable object, so what is the problem?
Error text: The query operator 'Last' is not supported.
Failing a solution I'm sure I can 'logic' my way around the problem, but this seemed elegant.
Thanks,
Jonathan