Given the following structure:
public class Contract
{
virtual int Id {get;set;}
virtual IList<Course> Courses {get;set;}
}
public class Course
{
virtual int Id {get;set;}
virtual IList<Schedule> Schedules {get;set;}
}
public class Schedule
{
virtual int Id {get;set;}
virtual DateTime Start {get;set;}
virtual DateTime End {get;set;}
}
I need to find if a given Contract has any Schedule (note how this goes through the Course relation) matching any of my new collection of Schedule objects from all the contracts in the database.
Edit:
My main problem is figuring it out a way (if possible and plausible) of doing the query against a collection of schedules, not just a scalar DateTime. This way, I figure I'd avoid doing an individual query for each Schedule instance. E.g., the structure would be something like:
Contract contract = new Contract
{
Courses = new List<Course>()
{
{
new List<Schedule>()
{
{new Schedule { Start = new DateTime(2011,01,01), End = new
DateTime(2011,01,31) } },
{new Schedule { Start = new DateTime(2011,02,01), End = new
DateTime(2011,02,27) } },
{new Schedule { Start = new DateTime(2011,03,01), End = new
DateTime(2011,03,15) } }
}
},
{
new List<Schedule>()
{
{new Schedule { Start = new DateTime(2010,12,12), End = new
DateTime(2010,12,31) } }
}
}
}
};
Do you think there's a way to query them all at once? Is it better to just do a .NET foreach loop and query individually?
Thanks in advance.