我正在尝试在嵌套的 $expanded
实体中使用过滤器查询。
例如,我正在使用以下查询。
webservice/Results?$expand=FoodDescriptions&$filter=substringof('Vod', FoodDescriptions/Description)&$format=json
执行此操作时,出现以下错误
{
"error": {
"code": "",
"message": {
"lang": "en-US",
"value": "Illegal query syntax. Segment before '/' is not an entity or complex type."
}
}
}
我从下面的公共服务示例中得到了这个查询。
https://services.odata.org/V2/Northwind/Northwind.svc/Orders?$expand=Customer&$filter=substringof('Henriette', Customer/ContactName)&$format=json
在这种情况下,我得到了正确的响应,任何人都可以对其进行测试。
谁能告诉我代码中出现这个特定错误的原因是什么?
答案 0 :(得分:0)
您的问题很可能出在 ODataConfig 下 - 您没有将 FoodDescriptions
设置为实体。
如果你到这里 [https://services.odata.org/V2/Northwind/Northwind.svc/$metadata],你可以找到这一行 <EntitySet Name="Customers" EntityType="NorthwindModel.Customer"/>
就您而言,您可能只是忘记将 FoodDescriptions 注册为实体。