My real-life example is too obscure to explain, but this is a pretty good approximation of what I'm trying to do...
Month
table has columns: Id
, Name
Holiday
table has columns: Id
, MonthId
, DayOfMonth
, Name
Appointment
table has columns: Id
, MonthId
, DayOfMonth
, Description
How do I produce a list of unique events (holidays and appointments) ordered by the month and the day of month?
Sample results:
Month Holiday Day Appointment Day
----------------------------------------
Nov Fly to NYC 25
Nov T-Giving 26
Nov Fly home 29
Dec Xmas 25
So, I want separate columns for holidays and events, but I want them all to be unique and listed in order of month-day.
Here's what I have so far (see inline comments):
var events =
from
m in GetMonths()
join
h in GetHolidays()
on m.Id equals h.MonthId
join
a in GetAppointments()
on m.Id equals a.MonthId
where
//something that narrows all combinations of events to only unique events
orderby
m.Id,
// something that interleaves h.DayOfMonth with m.DayOfMonth
select
new
{
Month = m.Name,
Holiday = h.Name,
HolidayDay = h.DayOfMonth,
Appointment = a.Description,
AppointmentDay = a.DayOfMonth
};