odata.net icon indicating copy to clipboard operation
odata.net copied to clipboard

ODL requires collection items on the RHS of "in" operator to be strings

Open gathogojr opened this issue 1 year ago • 0 comments

ODL requires collection items on the RHS of in operator to be strings. The following filter expression where DynamicPrimitiveCollectionProperty is a dynamic property is not parsed successfully.

$filter=DynamicPrimitiveCollectionProperty in (19,17)

Assemblies affected

  • Microsoft.OData.Core 8.x
  • Microsoft.OData.Core 7.x

Reproduce steps

var model = new EdmModel();

var customerEntityType = model.AddEntityType("NS", "Customer", baseType: null, isAbstract: false, isOpen: true);
customerEntityType.AddKeys(customerEntityType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32));

var entityContainer = model.AddEntityContainer("Default", "Container");

var customersEntitySet = entityContainer.AddEntitySet("Customers",
customerEntityType);

var filterClause = new ODataQueryOptionParser(
    model,
    customerEntityType,
    customersEntitySet, new Dictionary<string, string> { { "$filter", "DynamicPrimitiveCollectionProperty in (19,17)" } }).ParseFilter();

Expected result

The filter expression to be parsed successfully.

Actual result

image

Additional detail

Works if the collection items are strings, e.g., DynamicPrimitiveCollectionProperty in ('19','17')

gathogojr avatar Oct 25 '24 12:10 gathogojr