I am using Entity Framework. I want to get recently inserted (means last ten) ten rows. The table User has two columns:
userID
password
DateTime
How can I get most recent ten rows?
If you have a DateTime (or DATE) column then you can use something like this:
using(YourDbContext ctx = new YourDbContext())
{
var lastTenRows = ctx.Users.OrderByDescending(u => u.DateTimeColumn).Take(10).ToList();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With