是否可以在不提取数据的情况下找到odata总记录? [英] Can odata total records be found without fetching them?

查看:149
本文介绍了是否可以在不提取数据的情况下找到odata总记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Am创建分页并每页获取10条JSON记录:

  var coursemodel = query.Skip(skip).Take(take).ToList();

我需要在网页上显示数据库中可用记录的总数.例如,您正在查看x的20到30(其中x是记录总数).是否可以找到x而无需通过网络传输记录?

解决方案

进行了排序.这样做

http://yourserver7:40479/odata/Courses?$top=1&skip=1&$inlinecount=allpages

得到了这个

然后我从odata.count获得了值!我的网址获取了所有记录,在适用的地方添加$ filter ...

Am creating paging and fetching 10 JSON records per page:

  var coursemodel = query.Skip(skip).Take(take).ToList();

I need to display on the web page the total number of records available in database. For example, you are viewing 20 to 30 of x (where x is total number of records). Can x be found without transferring the records over the network?

解决方案

Sorted it. Did this

http://yourserver7:40479/odata/Courses?$top=1&skip=1&$inlinecount=allpages

Got this

 {
  "odata.metadata":"http://yourserver7:40479/odata/$metadata#Courses","odata.count":"503","value":[
    {
      "CourseID":20,"Name":"Name 20","Description":"Description 20","Guid":"Guid 20"
    }
  ]
}

I then got the value from odata.count! My url gets all records found, add $filter where applicable...

这篇关于是否可以在不提取数据的情况下找到odata总记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆