【问题标题】:OData - filter by nested propertyOData - 按嵌套属性过滤
【发布时间】:2013-05-15 16:49:54
【问题描述】:

有人知道如何针对嵌套属性表达 OData $filter 吗?

例如。我有以下 Atom 条目,

<entry>
...
 <m:properties>
...
  <d:RegardingObjectId m:type="Microsoft.Crm.Sdk.Data.Services.EntityReference">
  <d:Id m:type="Edm.Guid">3f3712fd-fc49-e211-8eb8-000c296272c8</d:Id> 
  <d:LogicalName>new_sportsleague</d:LogicalName> 
  <d:Name>Boca</d:Name> 
  </d:RegardingObjectId>

我想过滤那些有关于ObjectId/LogicalName eq 'new_sportsleague'的条目。

尝试使用“RegardingObjectId/LogicalName”和“RegardingObjectId.LogicalName”,但没有成功。

【问题讨论】:

    标签: odata


    【解决方案1】:

    'RegardingObjectId/LogicalName' 是正确的语法。

    例如:

    http://services.odata.org/v3/OData/OData.svc/Suppliers

    返回两个结果,而

    http://services.odata.org/v3/OData/OData.svc/Suppliers?$filter=Address/Street eq 'NE 228th'

    只返回一个。

    我在 OData 规范中没有看到明确说明使用复杂值的属性进行过滤是否合法的地方,但 WCF 数据服务似乎支持它。可能是其他 OData 实现没有。

    【讨论】:

    • 你是对的 Jen...Dynamics CRM 2011 似乎不支持此类查询。查询复杂类型时,我得到 $exception {“不支持对复杂类型 EntityReference 的属性 LogicalName 的引用”} System.Exception {Microsoft.Crm.CrmNotSupportedException} :-(
    【解决方案2】:

    使用以下 odata API 示例通过过滤数据访问嵌套属性

    http://192.168.50.152:50086/odata/StationOperationLogs/?$expand=ProductionStation,ProductionStation/ProductionUnit&$filter=ProductionStation/ProductionUnit/Id eq 2
    

    【讨论】:

    • 这对我不起作用。 .../IB?$expand=Organization&$filter=Organization/OrganizationId eq '2' error is ""Message": "URI 中指定的查询无效。属性“OrganizationId”的属性访问的父值不是单个值。属性访问只能应用于单个值。""
    猜你喜欢
    • 2019-03-22
    • 2022-11-01
    • 2016-02-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-18
    • 2021-09-27
    • 2016-11-03
    相关资源
    最近更新 更多