Внезапная задача



Найдите отличия в приведённых фрагментах кода, и в каком из них находится баг?



1️⃣





var children = _childrenRepository.GetByParentIds(parentIds);

return parentIds.ToDictionary(

parentId => parentId,

parentId => children.Where(child => child.ParentId == parentId).ToList());





2️⃣





var children = _childrenRepository.GetByParentIds(parentIds);

var grouped = children.GroupBy(child => child.ParentId);

return grouped

.ToDictionary(

childrenGroup => childrenGroup.Key,

childrenGroup => childrenGroup.ToList());