Vac*_*ano 1 wcf-data-services odata
假设我在Netflix OData端点上有以下查询:
Titles.Where(x=>x.AverageRating > 3.0)
Run Code Online (Sandbox Code Playgroud)
有没有办法用来.IncludeTotalCount()获得符合where子句的标题数量?(不是Titles资源中项目的总数.)
我查看了这里提供的代码:http://msdn.microsoft.com/en-us/library/ee474390.aspx
但它似乎不适用于where子句.
我试过这个,它工作得很好:
DemoService ctx = new DemoService(new Uri("http://services.odata.org/OData/OData.svc/"));
var query = (DataServiceQuery<Product>)ctx.Products.IncludeTotalCount().Where(p => p.Rating < 4);
QueryOperationResponse<Product> response = (QueryOperationResponse<Product>)query.Execute();
Console.WriteLine(response.TotalCount);
foreach (var i in response)
{
Console.WriteLine(i.Name + ", " + i.Rating.ToString());
}
Run Code Online (Sandbox Code Playgroud)
在你的情况下,"它不起作用"是什么意思?
| 归档时间: |
|
| 查看次数: |
1646 次 |
| 最近记录: |