1
I have this foreach, in a table with more than 5000 records. There are only 6 types of business unit. I would like that in the foreach and Ingl, when a type of UN appears, it loads and then does not repeat it, that is, it carries another different and so on, so that the result comes only 6 records. Down with my foreach.
foreach (var _idmotivo in monta_arvore)
{
_listaUnidade = db.Apresentacao
.Where(un => un.Codigo_Unidade_Negocio == _idmotivo.Codigo_Unidade_Negocio)
.Select(u => new MontaArvoreAcao
{
Unidade_Negocio = u.Unidade_Negocio,
Codigo_Unidade_Negocio = u.Codigo_Unidade_Negocio
}).ToList().OrderBy(o => o.Unidade_Negocio);
}
I don’t understand which one you want to do it in. It’s in the tree or in the?
– Diego Zanardo
In the _list, as it brings me several names and would not like to see repeated. I used distinct and nothing.
– pnet