I have a simple if
statement which, based on user input, determines which expression is going to be utilized. It looks like it can be done better.
Func<Unit, bool> exp;
if (onlyChildren)
exp = u => u.PhaseId == id;
else
exp = u => u.PhaseId != id;
var unitGroups = _db.Units.Where(exp).GroupBy(m => m.UnitTemplate, (m, group) => new UnitTemplateZoneVm()
{
Id = m.Id,
Units = group.ToList()
}).ToList();