1
Is there any LINQ method that returns a default value of my preference, which fulfills the role of this method in a more efficient way?
public static int? procurarIdPorCpf(string cpf)
{
using (Contexto context = new Contexto())
{
if (context.pessoaFisica.Any(p => p.CPF.Equals(cpf)))
return context.pessoaFisica.First(p => p.CPF.Equals(cpf)).ID;
else
return null;
}
}
What would be "more efficient" in your view? A more succinct syntax?
– Leonel Sanches da Silva