I have run into a bit of trouble with this linq query:

I have a list (`allStats`) filled with data (see `allItems` class)
the list contains several entries from different days which I need to break down so they are seperated by month and weeknumber like so:

```
    MonthNumber: 1,
    List<Weeks> Weeks:
        WeekNumber: 1,
        List<Days> Days:
            PunchedInLate: true,
            PunchedOutLate: false,
            PunchInDate: 2013-1-1 08:20:10,
            PunchOutDate: 2013-1-1 15:00:00
            PunchedInLate: true,
            PunchedOutLate: false,
            PunchInDate: 2013-1-2 08:20:10,
            PunchOutDate: 2013-1-2 15:00:00
            ...
            PunchedInLate: true,
            PunchedOutLate: false,
            PunchInDate: 2013-1-5 08:20:10,
            PunchOutDate: 2013-1-5 15:00:00
    MonthNumber: 1,
    List<Weeks> Weeks:
        WeekNumber: 2,
        List<Days> Days:
            PunchedInLate: true,
            PunchedOutLate: false,
            PunchInDate: 2013-1-10 08:20:10,
            PunchOutDate: 2013-1-10 15:00:00
            PunchedInLate: true,
            PunchedOutLate: false,
            PunchInDate: 2013-1-12 08:20:10,
            PunchOutDate: 2013-1-12 15:00:00

```

[PasteBin - Here you can download a sample program so you can run it from your machine](http://pastebin.com/sC09RaNb)

It is essentially an addon to the answer of this question that I am trying to create:
[SO - Splitting parts of a List into 2 List's and joining those 2](https://stackoverflow.com/questions/15275058/splitting-parts-of-a-listt-into-2-listts-and-joining-those-2)

> 
> **EDIT:** I am sorry, I forgot to mention that I've tried the .ToList() method at the end instead of the cast at the start which produces this error:
> 
> 
> 

`Cannot implicitly convert type 'System.Collections.Generic.List<System.Collections.Generic.IEnumerable<TestClass.Weeks>>' to 'System.Collections.Generic.List<TestClass.Weeks>'`

```
public class allItems
{
    public DateTime PunchInDate { get; set; }
    public DateTime PunchOutDate { get; set; }
    public DayOfWeek DayOfWeek { get; set; }
    public int WeekNumber { get; set; }
    public int MonthNumber { get; set; }
    public bool PunchedInLate { get; set; }
    public bool PunchedOutLate { get; set; }
}
public class Months
{
    public int MonthNumber { get; set; }
    public List<Weeks> Weeks { get; set; }
}
public class Weeks
{
    public int WeekNumber { get; set; }
    public List<Days> Days { get; set; }
}
public class Days
{
    public bool PunchedInLate { get; set; }
    public bool PunchedOutLate { get; set; }
    public DateTime PunchInDate { get; set; }
    public DateTime PunchOutDate { get; set; }
    public DayOfWeek DayOfWeek { get; set; } 
}

```

And the code:

```
List<allItems> allStats = getAllStats(userId);
List<Months> stats = new List<Months>();
var asItems =
    from item in allStats
    group item by new { month = item.MonthNumber } into Month
    select new Months()
    {
        MonthNumber = Month.Key.month,
        Weeks = Month.Select(week =>
            from weeks in allStats
            group weeks by new { week = weeks.WeekNumber } into Week
            select new Weeks()
            {
                //WeekNumber = week.WeekNumber,
                WeekNumber = Week.Key.week, // I just noticed that I guess that I 
                                            // need this here, so I can group the 
                Days = Month.Select(days => // days correctly, right?
                    new Days()
                    {
                        PunchedInLate = days.PunchedInLate,
                        PunchedOutLate = days.PunchedOutLate,
                        DayOfWeek = days.DayOfWeek,
                        PunchInDate = days.PunchInDate,
                        PunchOutDate = days.PunchOutDate
                    }).ToList()
            }).ToList()
    };
List<Months> stat = asItems.ToList();

```