I’m looking for a way to get the Entity Framework to return one record for every minute in a database field e.g. for the table below:
Message | Timestamp
--------+--------------------
a | 2011-01-02 12:31:10
b | 2011-01-02 12:31:15
c | 2011-01-02 12:31:59
d | 2011-01-02 12:32:01
e | 2011-01-02 12:32:30
f | 2011-01-02 12:33:10
I want a query that returns
c,e,f (c and e are selected because they are the latest entries)
Is this possibly with a single query? The database is quite large so I don’t want to retrieve all records and select them in a loop.
I use Linq for an in-memory collection instead of EF, but you should be able to adapt this easily.