C# Entity Framework Pagination

前端 未结 5 1299
陌清茗
陌清茗 2020-12-09 04:33

Is there a way to get the row count of a complex Linq query and millions of records without hitting the db twice or writing 2 separate queries??

5条回答
  •  轮回少年
    2020-12-09 05:12

    it is so easy on sql server . you can write this query :

    select count() over(), table.* from table
    

    the count () over() will return the count of total row in result , So you don't need to run two query.. Remember that you should run raw sql on your context or use dapper that return result as view model

提交回复
热议问题