/// <summary> /// Parses <paramref name="odataOptions"/> used parameters and returns <see cref="ODataOperators"/> /// that represents the set of operators used by this odataOptions. /// </summary> /// <typeparam name="T">The entity type for the odataOptions.</typeparam> /// <param name="odataOptions">The <see cref="ODataQueryOptions"/> to be validated.</param> /// <returns>The <see cref="ODataOperators"/> representation of the operators in the OData options. /// If no operator is used the result will be <see cref="ODataOperators.none"/>.</returns> public static ODataOperators ODataOptionsMap <T>(ODataQueryOptions <T> odataOptions) { if (odataOptions == null) { return(0); } ODataOperators result = ODataOperators.None; foreach (var odataOperator in Enum.GetNames(typeof(ODataOperators))) { var rawValuesProperty = typeof(ODataRawQueryOptions).GetProperty(odataOperator); if (rawValuesProperty != null && rawValuesProperty.GetValue(odataOptions.RawValues, null) != null) { result |= (ODataOperators)Enum.Parse(typeof(ODataOperators), odataOperator, ignoreCase: true); } } return(result); }
public void QueryBuilder_BuildQuery_One_filter(ODataOperators oDataOperator, string expectedQuery) { var searchOptions = new List <SearchQueryParameter> { new SearchQueryParameter() { Name = TestAzureSearchProperties.HotelName, Value = "Double Sanctuary Resort", Parent = TestAzureSearchProperties.HotelName, ODataOperator = oDataOperator } }; var searchParameters = new List <SearchQueryParameters>() { new SearchQueryParameters(searchOptions) }; var actualQuery = _queryBuilder.BuildQuery(null, searchParameters.ToArray()); actualQuery.Should().Be(expectedQuery); }