Traversing a nested LINQ query in of anonymous objects in C# view via ASP.NET MVC
Hi, done a lot of searching and reading but still require some specific information. I have the following code:
       List<DateTime> range = getRangeCollection();
        var range = (
             from years in rangeData 
             group years by years.Year 
             into yearsData 
             select new {
                 year = yearsData.Key,
                 months = (
                     from month in yearsData 
                     group month by month.Month 
                     into monthsData
                     select new {
                         month = monthsData.Key,
                         days = (
                             from days in monthsData
                             group days by days.Day
                             into daysData
                             select new {
                                 day = monthsData.Key, 
                                 days = daysData
                             })
                     })
             }).ToList();
I can send this as a ViewData property to a view like so.
    <% foreach (var date in ((IEnumerable)ViewData["range"])) { 
// another foreach needed to access date.month and loop days inside.
 %> 
 <p><%=date%></p>
  <% } %>
But I want use it to generate HTML that looks like the following:
2009
  January
    (all the days in jan)
  February
    (all the days in feb)
    ..ect
2010
  Janurary
    (all the days in jan)
  February
    ...ect
I'm not sure if my LINQ is correct, but I'm trying to traverse the results in a ASP.NET MVC environment. I'm trying to get my head around IEnumerable and IQueryable. Am I on the right track?