SELECT
S.Name, Result.Id, Longitud, Latitud, Trandate, EndTrandate,
Salesman, TranId, ClientId, TranType, TranStatus, Result.Division_Id,
UniqueTransactionId, Result.RecordId
FROM
(SELECT
ROW_NUMBER() OVER (PARTITION BY Salesman ORDER BY EndTranDate DESC) AS RowNum,
Id, Longitud, Latitud, Trandate, EndTrandate, Salesman, TranId,
ClientId, TranType, TranStatus, Division_Id, UniqueTransactionId,
RecordId
FROM
LocationHistory) AS Result
INNER JOIN
Salesman S ON Result.Salesman = S.Id
WHERE
Result.RowNum = 1
ORDER BY
Salesman
Asked
Active
Viewed 53 times
1

marc_s
- 732,580
- 175
- 1,330
- 1,459

HackingPills
- 11
- 1
-
Perhaps my [SQL to LINQ Recipe](https://stackoverflow.com/questions/49245160/sql-to-linq-with-multiple-join-count-and-left-join/49245786#49245786) might prove helpful. – NetMage Jul 08 '19 at 22:24
-
@NetMage I doubt it would - your "recipe" is too generic and does not take into account EF Core specifics. At the same time itl does not cover SQL features not supported by LINQ like `OVER` and `PARTITION` clauses of the OP query which simply have no LINQ translation except the query provider supports custom extensions for that . – Ivan Stoev Jul 09 '19 at 11:10
-
@IvanStoev I am reluctant to add simulations for some of those as I think it becomes too complicated to be a recipe... – NetMage Jul 09 '19 at 17:52