0
我想将此sql语句转换为Linq格式,但没有成功。我不想显示所有数据,而是想显示每个类别的10个项目。任何帮助都会很棒。如何将SQL转换为Linq
select *
from (
select *,
row_number() over(partition by T.category order by T.id desc) as rn
from clothes as T
) as T
where T.rn <= 10;
我在linq的尝试在下面;
var query= from (subquery) as DB in dataContext.table where DB.rn <=10;
select DB;
var subquery = row_number() over(partition by DB.id order by DB.category desc) as rn from DB in dataContext.table as DB
select DB;
可能重复【行\ _number在Linq中(用xxx分区)?](http://stackoverflow.com/问题/ 9980568/row-number-over-partition-by-xxx-in-linq) – Chris