First I made this code:
for (int i = 0; i < vlstAcessos.Count - 1; i++)
{
if (vlstAcessos[i].DsURLTransacao == "frmANAAguardeProcesso.aspx")
transacaoANA = vlstAcessos[i].DsURLTransacao = "frmANAAguardeProcesso.aspx";
else if (vlstAcessos[i].DsURLTransacao == "frmPVListaProcessos.aspx")
transacaoPV = vlstAcessos[i].DsURLTransacao = "frmPVListaProcessos.aspx";
else if (vlstAcessos[i].DsURLTransacao == "frmGESStatusPriorizar.aspx")
transacaoGestor = vlstAcessos[i].DsURLTransacao = "frmGESStatusPriorizar.aspx";
else if (vlstAcessos[i].DsURLTransacao == "frmConsultarProcessos.aspx")
transacaoConsulta = vlstAcessos[i].DsURLTransacao = "frmConsultarProcessos.aspx";
}
Then I saw that this code is ugly and I did this:
transacaoPV = vlstAcessos.Any(l => l.DsURLTransacao == "frmPVListaProcessos.aspx").ToString();
I know perfectly well that the lambda expression above will return a True or False. The question is: Is it like with a Lambda I load a variable string with the value of the expression? That is, transacaoPV
gets the value of: frmPVListaProcessos.aspx
These lambdas replace the above IF, right?
transacaoGestor = vlstAcessos.Select(l => l.DsURLTransacao).FirstOrDefault(d => d == "frmGESStatusPriorizar.aspx");
transacaoPV = vlstAcessos.Select(l => l.DsURLTransacao).FirstOrDefault(d => d == "frmPVListaProcessos.aspx");
transacaoANA = vlstAcessos.Select(l => l.DsURLTransacao).FirstOrDefault(d => d == "frmANAAguardeProcesso.aspx");
transacaoConsulta = vlstAcessos.Select(l => l.DsURLTransacao).FirstOrDefault(d => d == "frmConsultarProcessos.aspx");