Simple.Data Group By

742 views Asked by At

I'm new to Simple.Data. But i'm having a really hard time finding out how to do a 'group by'.

What I want is very basic.

Table looks like:

+________+
| cards  |
+________+
| id     |
| number |
| date   |
+________+

I want the equivalent of this query:

select * from (select * from cards order by date desc) as m group by number;

So I get the latest record, 1 for each number.

Any help is appreciated, even if I'm barking up the wrong tree

Thanks

1

There are 1 answers

0
Mark Rendle On BEST ANSWER

Simple.Data infers GROUP BY clauses based on your use of aggregates.

db.Cards.All().Select(db.Cards.Number, db.Cards.Date.Max());

will give you the max date for each number.