private Dictionary <int, ObjectSingleAttributeDTO> TranslateToSingleAttributeTypeDtos( List <MpObjectAttribute> mpObjectAttributes, List <MpAttribute> mpAttributes) { var mpFilteredAttributes = mpAttributes.Where(x => x.PreventMultipleSelection == true).ToList(); var attributeTypesDictionary = mpFilteredAttributes .Select(x => new { x.AttributeTypeId, x.AttributeTypeName }) .Distinct() .ToDictionary(mpAttributeType => mpAttributeType.AttributeTypeId, mpAttributeType => new ObjectSingleAttributeDTO()); foreach (var mpObjectAttribute in mpObjectAttributes) { if (!attributeTypesDictionary.ContainsKey(mpObjectAttribute.AttributeTypeId)) { continue; } if (!mpAttributes.Exists(x => x.AttributeId == mpObjectAttribute.AttributeId)) { continue; } var mpAttribute = mpAttributes.First(x => x.AttributeId == mpObjectAttribute.AttributeId); var attribute = _attributeService.ConvertAttributeToAttributeDto(mpAttribute); var objectSingleAttribute = attributeTypesDictionary[mpObjectAttribute.AttributeTypeId]; objectSingleAttribute.Value = attribute; objectSingleAttribute.Notes = mpObjectAttribute.Notes; } return(attributeTypesDictionary); }