我可以使用 Linq to SQL 实现这个吗?
今天我进行了两个查询,一个是用来计算数量的,另一个是用来选择页面的:
select top 10 count(1) over(), * from product
今天我进行了两个查询,一个是用来计算数量的,另一个是用来选择页面的:
select count(1) from product
select top 10 * from product
count(1) over()
的查询更好,因为它可以一次返回总数和页面。我对这些查询进行了分析,在原始查询中添加 count(1) over()
不会增加任何毫秒。
Take(10)
来获得与原帖中的SQL相同的结果。 - Matt Ellen