Currently I return everything from my Repo as a List. I am looking to change these to IQueryable just so people can refine the results and not suffer from another sql request(I am using nhibernate).
I have a question though to make life easier on everyone I have something like this in my repo
public List<CalendarAppointment> GetAppointment(Student student, DateTime start, DateTime end)
{
List<CalendarAppointment> appointments = session.Query<CalendarAppointment>().Where(x => x.Student.Id == student.Id
&& x.Start.Date >= start.Date && x.End.Date <= end.Date)
.Take(QueryLimits.Appointments).ToList();
return appointments.ConvertToLocalTime(student);
}
public static List<CalendarAppointment> ConvertToUtcTime(this List<CalendarAppointment> appointments, Student student)
{
if (student != null)
{
TimeZoneInfo info = TimeZoneInfo.FindSystemTimeZoneById(student.TimeZoneId);
foreach (var appointment in appointments)
{
appointment.Start = TimeZoneInfo.ConvertTimeToUtc(appointment.Start,info);
appointment.End = TimeZoneInfo.ConvertTimeToUtc(appointment.End,info);
}
}
return appointments;
}
So I get currently the results back and then convert the times into local time. This way we don't have to worry about it.
What happens if I do this with IQueryable. Will it go off and trigger the sql anyways?