如何编写查询以使用ODATA资源中扩展实体的属性获取结果?

时间:2019-05-28 16:39:05

标签: odata

我正在尝试从OData V4资源获得结果。我要过滤的属性是“ Meeting_Date”属性,该属性在展开的实体“ CommitteeMeetings”下可见。但是,当尝试使用此属性进行过滤时,出现错误,提示“找不到类型为'Magic_API.Models.Data.Committees'的名为'Meeting_Date'的属性”。 委员会是基础实体,并且在扩展时,Meeting_Date仅存在于CommitteeMeetings下。如何正确编写查询,以便获得等于指定的Meeting_Date的结果?

我尝试过类似的查询: http://serviceurl/Committees?$ expand = CommitteeMeetings&$ filter =(Meeting_Date eq'20190111')

我得到:“在类型'Magic_API.Models.Data.Committees'上找不到名为'Meeting_Date'的属性。”

我也尝试过: http://serviceurl/Committees?$ expand = CommitteeMeetings&$ filter =(CommitteeMeetings / Meeting_Date eq'20190111')

我得到:内部错误,正在验证Filter子句”

例如,当我请求时: http://serviceurl/Committees?$ expand =委员会会议

我这样返回结果:

        {
            "Association_ID": "ABC",
            "Committee_ID": "16AB",
            "Committee_Descrip": "2019 XYZ",
            "Committee_Type_Code": "CO",
            "Coordinator_1": "",
            "Coordinator_2": "",
            "Committee_Status": "I",
            "Meeting_Week": 1,
            "Meeting_Day": 1,
            "Start_Time": "\u0000",
            "End_Time": "\u0000",
            "Meeting_Location": "XYZ",
            "Comment": "",
            "Share_National": "N",
            "Share_State": "N",
            "Share_Local": "N",
            "Send_Code": "N",
            "Owner": "",
            "Last_Meeting_Number": 9,
            "CommitteeMeetings": {
                "Association_ID": "ABC",
                "Committee_ID": "16AB",
                "Meeting_Date": "20190130",
                "Start_Time": "093000",
                "End_Time": "103000",
                "Location_Code": "XYZ123",
                "Comment": "XYZ Committee Meeting",
                "Status": "A",
                "Attend_Record_Create": "",
                "Meeting_Number": 1,
                "Web_Description": " ",
                "Last_Modified_Date_Time": "2019-01-27T15:00:53-07:00"
            }
        },
        {
            "Association_ID": "RFA",
            "Committee_ID": "16AB",
            "Committee_Descrip": "2019 RFA",
            "Committee_Type_Code": "CO",
            "Coordinator_1": "",
            "Coordinator_2": "",
            "Committee_Status": "I",
            "Meeting_Week": 1,
            "Meeting_Day": 1,
            "Start_Time": "\u0000",
            "End_Time": "\u0000",
            "Meeting_Location": "RFA",
            "Comment": "",
            "Share_National": "N",
            "Share_State": "N",
            "Share_Local": "N",
            "Send_Code": "N",
            "Owner": "",
            "Last_Meeting_Number": 9,
            "CommitteeMeetings": {
                "Association_ID": "RFA",
                "Committee_ID": "16AB",
                "Meeting_Date": "20190220",
                "Start_Time": "093000",
                "End_Time": "103000",
                "Location_Code": "XYZ123",
                "Comment": "RFA Committee Meeting",
                "Status": "A",
                "Attend_Record_Create": "",
                "Meeting_Number": 1,
                "Web_Description": " ",
                "Last_Modified_Date_Time": "2019-02-12T15:00:53-07:00"
            }
        },

我正在尝试编写适当的查询,以便我可以返回在CommitteeMeetings Meeting_Date上大于或等于我指定的日期的所有匹配结果。但是我只会得到有关语法的错误或有关过滤器的内部错误。我想我错过了一些东西,因为我是OData语法的新手,并且以前从未使用过它。如果有人可以帮助我正确地编写查询,我将不胜感激。谢谢!

0 个答案:

没有答案