且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

是否可以在不提取数据的情况下找到odata总记录?

更新时间:2023-09-20 12:49:28

进行了排序.这样做

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...