我对如何将此查询更改为LINQ
感到困惑 select
CONTENT
from
(
select
CONTENT,
CAM_ID,
max(CAM_ID) over (partition by DOCUMENT_ID) MAX_ID
from
T_CAM_REVISION
where
DOCUMENT_ID = '101'
)
where
CAM_ID = MAX_ID
所以我可以获得单一的内容价值。
答案 0 :(得分:2)
在LINQ中无法执行max(...) over (...)
。这是一个等效的查询:
var maxCamID =
context.T_CAM_REVISION
.Where(rev => rev.DOCUMENT_ID == "101")
.Max(rev => rev.CAM_ID);
var query =
from rev in context.T_CAM_REVISION
where rev.CAM_ID == maxCamID
where rev.DOCUMENT_ID == "101"
select rev.CONTENT;
如果您只想要一个结果:
var result =
context.T_CAM_REVISION
.First(rev => rev.CAM_ID == maxCamID
&& rev.DOCUMENT_ID == "101")
.CONTENT;