this is data
id code status
1 1 5
2 1 6
3 2 8
4 2 9
5 2 12
6 3 15
7 3 19
8 3 13
what I need as a result is this:
id code status
2 1 6
5 2 12
8 3 19
in other words I need al rows with max id in grouping by code.
for example, for code 3, ids are 6, 7, 8 and I need row with 8.
equivalent sql query would be
select *
from t inner join (select max(id) maxId from t group by code) t1
on t.id = t1.maxId
Status column is irelevant, it's just an atribute.
What is the linq query for something like this?
Thanks in advance.