I need a list of musicians without repetitions, but it is bringing duplicate values, according to the amount of songs that each Musician has, how do I bring just one Musician?
public ActionResult SelecaoMusico()
{
List<Musico> musicos = new List<Musico>();
Musico musico;
List<Musica> musicas = db.Musicas.ToList();
foreach(var musica in musicas){
int idMusica = musica.MusicaID;
int musicoIdMusica = musica.MusicoID;
musico = db.Musico.Where(p => p.MusicoID.Equals(musicoIdMusica)).SingleOrDefault();
musicos.Add(musico);
}
return Json(musicos);
}