There is the possibility of using MAX
in expression queries lambdas
, for example:
I would like to get all the records at the age of 18 and get the only last record inserted in the database, that is, with the longest registration date.
Lista.FirstOrDefault(x => x.Idade.Equals(18) && x.DataCadastro);