我正在努力将SQL查询转换为LINQ
SELECT * FROM Log x
JOIN (SELECT p.objId,
MAX(modifiedDateTime) AS latestDateTime
FROM Log p
GROUP BY p.objId) y ON y.objId= x.objId
AND y.latestDateTime = x.modifiedDateTime
请建议。这是我到目前为止的地方
var query1 = from x in query
join y in query
on new {x.objId, x.modifiedDateTime}
equals new {y.objId, ...(Max)}
答案 0 :(得分:1)
您创建的两个新匿名对象将永远不会相等。您需要直接比较这些值。尝试: 在x.objID上等于y.objID&& x.modifiedDateTime等于y.lastestDateTime