3
使用oData v4(特別是Microsoft.AspNet.Odata 5.3.0和Microsoft.Odata.Core 6.7.0),我的查詢操作符,特別是$ select,正在獲取即使我將函數聲明爲IsComposable = true,也會忽略函數。
任何建議如何使這種情況下工作?我主要對$ filter和$ select感興趣。
- 最大
詳細(基於內https://github.com/OData/ODataSamples FunctionSamples)
嘗試查詢:http://localhost:9010/odata/Products/Default.Top10() $選擇=名稱
期望的迴應(摘錄)
{
Name: "Product 48"
}
實際響應(節選)
{
Id: 48,
Name: "Product 48",
Price: 986.2794056470876
}
函數聲明:
// Function bound to a collection
// Returns the top 10 product, a collection
productType.Collection
.Function("Top10")
.ReturnsCollectionFromEntitySet<Product>("Products")
.IsComposable = true;
控制器:
// Returns the top ten most expensive products
[HttpGet]
public IHttpActionResult Top10()
{
var retval = _data.Values.OrderByDescending(p => p.Price).Take(10).ToList();
return Ok(retval);
}