Simlicity is not always so great…

While making some changes to the skills on my website I noticed a design flaw that I created while simplifying some display options.

public async Task<ActionResult> Index()


Dictionary<string, List<Skill>> skillDictionary = await db.Skills
.GroupBy(s => s.SkillGroup)
.ToDictionaryAsync(g => g.Key, g => g.OrderBy(v=>(int)v.SkillLevel).ToList());

ViewBag.GroupedSkills = skillDictionary;
return View();

Super simple ey? Yes but one fatal flaw, I cannot sort the skill groups this way… This needs fixing pronto, two solutions I came up with:

  1. Adding an OrderBy and in the ordering, function pass a lambda expression to order the skill groups by the amount of ‘Advanced’ skills
  2. Adding two new Entities:
    1. SkillGroup
    2. SkillToGroupAssigement

While migrating the whole database and is always a bit scary I think I’ll go for option two it’s a lot more long lasting and allows me to custom sort Skill Groups.