List matching with boolean return

1

I have two lists IEnumerables which I must compare to make the ids of the lists are projected on a grid, the ids are team professionals and the comparison is for when two professionals are selected, the list return the equipment where only they are EJ:

public async Task<MiniEquipoModel> GetMiniEquipoGrillaAsync(SearchFilter filter,
CancellationToken cancellationToken = default(CancellationToken))
{
//Buscar profesionales que coincidan en miniequipos
  var MiniEquipo = await _miniEquipoCommonRepository.GetMiniEquipoByProfesionalAsync(filter, cancellationToken).ConfigureAwait(false);

var result = new MiniEquipoModel();

var grupoMiniEquipo = new List<MiniEquipoCommonModel>();

foreach (var item in MiniEquipo.ListaMiniEquipo)
{
 if (ValidarProfesionalesMinimos(item.Ids, filter.PersonaIds))
 grupoMiniEquipo.Add(item);
}

result.ListaMiniEquipo = grupoMiniEquipo;
result.Total = MiniEquipo.Total;

return result;
}


  #region Métodos privados

        private bool ValidarProfesionalesMinimos(IEnumerable<int> ids, IEnumerable<int> personaIds)
{
 var profesionalIds = _miniEquipoRepository.GetProfesional(ids);
 var result = profesionalIds.SequenceEqual(personaIds);

 return result;
}
        #endregion

in the private method as I do so that I return the comparison in "true" (until now it returns false and that makes that in the part above in the IF I do not add the item in GrupoMiniEquipo), I need that I return true in the comparison in the private method. but I do not know how to do it right

    
asked by tatan66 05.11.2018 в 21:40
source

1 answer

1

SequenceEqual compares the elements are the same and in the same order . The list [1, 2, 3] is not equal to [3, 2, 1] for this method. What you can do is order both lists before:

lista1.OrderBy(x => x).SequenceEqual(lista2.OrderBy(x => x));
    
answered by 05.11.2018 в 22:00