OData V4 + WebAPI Filter by Int Value of Enum?

前端 未结 2 1810
南旧
南旧 2020-12-31 20:12

OData V4 has enum support but it appears you have to search by the namespace only. How does one now search by the value instead of the text representation?

In V3 of

2条回答
  •  离开以前
    2020-12-31 20:51

    With v4, you have to add the namespace as the prefix and surround the value with the single quote such as http://services.odata.org/V4/(S(m1bhpaebr1yvzx5vtz5v4ur1))/TripPinServiceRW/People?$filter=Gender%20eq%20Microsoft.OData.SampleService.Models.TripPin.PersonGender'1' , where 1 represents Female.

    Here is a quotation from the ABNF of the protocol http://docs.oasis-open.org/odata/odata/v4.0/os/abnf/odata-abnf-construction-rules.txt:

    enum            = qualifiedEnumTypeName SQUOTE enumValue SQUOTE
    enumValue       = singleEnumValue *( COMMA singleEnumValue )
    singleEnumValue = enumerationMember / enumMemberValue
    enumMemberValue = int64Value
    

提交回复
热议问题