Take Last 5 Records when I don't have a CreatedAt field
Options
Hello
How can I grab the last 5 records in the table when I don't have a DateTime field for CreatedAt?
I did search on Google, and came across this, but this doesn't seem to work in LINQPad, it says it is unsupported.
Thank you.
How can I grab the last 5 records in the table when I don't have a DateTime field for CreatedAt?
I did search on Google, and came across this, but this doesn't seem to work in LINQPad, it says it is unsupported.
.Reverse().Take(5).Reverse()Any help would be greatly appreciated.
Thank you.
Comments
-
why not just
TableNamePlurals.Skip(TableNamePlurals.Count() - 5)
? but if you're doing it without ordering by anything, (depending on your datasource) the results are not deterministic - I suggest ordering by PK/ID first. -
It might help if you would describe the collection you are working with. You want the last 5 based on what?