using System.Collections.Generic;
public static void Main()
List<int> days = new List<int>();
List<LinqTest> testList = new List<LinqTest>();
testList.Add(new LinqTest() { id = 1234, date = 3, employeeCount = 30});
testList.Add(new LinqTest() { id = 1235, date = 2, employeeCount = 100});
testList.Add(new LinqTest() { id = 1236, date = 3, employeeCount = 60});
testList.Add(new LinqTest() { id = 1237, date = 4, employeeCount = 45});
testList.Add(new LinqTest() { id = 1238, date = 5, employeeCount = 13});
testList.Add(new LinqTest() { id = 1234, date = 6, employeeCount = 2});
testList.Add(new LinqTest() { id = 1234, date = 7, employeeCount = 200});
testList.Add(new LinqTest() { id = 1234, date = 2, employeeCount = 36});
testList.Add(new LinqTest() { id = 1236, date = 6, employeeCount = 2});
testList.Add(new LinqTest() { id = 1234, date = 6, employeeCount = 100});
var itemsWithDefaults = (from d in days
join l in testList on d equals l.date into dl
from dayList in dl.DefaultIfEmpty()
id = dayList == null ? 0 : dayList.id,
employeeCount = dayList == null ? 0 : dayList.employeeCount
var map = itemsWithDefaults
.ToDictionary(x => x.Key, x => x.ToList());
Console.WriteLine(key.Key);
foreach(var item in key.Value)
Console.WriteLine(item.id);
Console.WriteLine(key.Value.Sum(v => v.employeeCount));
nextDay = (int)map.OrderBy(m => m.Value.Sum(v => v.employeeCount)).ThenBy(m => (int)m.Key).FirstOrDefault().Key;
Console.WriteLine((DayOfWeek)nextDay);
public int id { get; set; }
public int date { get; set; }
public int employeeCount { get; set; }