MVC - Why does not this code return the last value, but returns the largest value?
int LastRegister = db.suma1.OrderByDescending(x => x.suma).First().suma;
MVC - Why does not this code return the last value, but returns the largest value?
int LastRegister = db.suma1.OrderByDescending(x => x.suma).First().suma;
Because you are sorting in descending order on all your sums, not among the records.
You can call it by the id or your accountant
int LastRegister = db.suma1.OrderByDescending(x => x.id).First().suma;
Or use the function of the last one exactly
int LastRegister = db.suma1.LastorDefault().suma;