你问问题最好把表结构发出来,这样也节约你的时间。
=================================================
应该类似如下Linq
(
from c in 收藏表上下文
group c by c.产品ID into g
orderby g.Count() descending
select new
{
A=g.Key,
B=g.Count()
}
).Take(10)
------------
sql
SELECT TOP (10) [t1].[产品ID] AS [A], [t1].[value] AS [B]
FROM (
SELECT COUNT(*) AS [value],[t0].[产品ID]
FROM [收藏表] AS [t0]
GROUP BY [t0].[产品ID]
) AS [t1]
ORDER BY [t1].[value] DESC