Given the following data, how does one select only the latest version for each item using LINQ?
ItemId, Version
===================
A, 1
A, 2
A, 3
B, 8
B, 9,
C, 10
C, 11
The desired results are:
A, 3
B, 9
C, 11
In TSQL, I would do something like so:
SELECT * FROM MyTable AS Tbl1
WHERE Tbl1.Version =
(SELECT MAX(Version)
FROM MyTable
WHERE MyTable.ItemId = Tbl1.ItemId)
I would go with something like:
EDIT: Fixed bad SQL output.