Open bjr001 opened 3 years ago
From the documentation itself I would assume it's correct as this produces the correct predicate:
[Fact]
public void ExpressionPropertySetTextAttributeValueEqual()
{
Expression<Func<ProductProjection, bool>> expression = p => p.Variants.Any(variant => variant.Attributes.Any(a => a.ToTextAttribute().Name == "text-name" && a.ToSetTextAttribute().Value.ContainsAny("text-value")));
IQueryPredicateExpressionVisitor queryPredicateExpressionVisitor = this.linqFixture.GetService<IQueryPredicateExpressionVisitor>();
string result = queryPredicateExpressionVisitor.Render(expression);
Assert.Equal("variants(attributes(name = \"text-name\" and value contains any (\"text-value\")))", result);
}
And as you can see the message comes back from the API that it doesn't support this option. This means it's not an issue of the SDK itself.
Could you please forward this to our support at https://support.commercetools.com
Okay, so I get in contact with CT support and according to them the "in" operator should be used:
We used the 'in' operator based on the documentation provided here where it offers query predicate examples:
https://docs.commercetools.com/api/predicates/query#query-predicates-by-example
// Check whether a field's value is or is not contained in // a specified set of values. age in (42, 43, 44) age not in (42, 43, 44)
So I tried as following....
var queryCommand = new QueryCommand<ProductProjection>();
queryCommand .Where(p => p.Variants.Any(variant => variant.Attributes.Any(attribute =>
attribute.Name == "MyCustomAttribute" &&
attribute.ToTextAttribute().Value.In("MyCustomValue"))));
...which does return expected result although "MyCustomAttribute" is set of text.
Does this mean there will be an upcoming change to .NET Sdk?
What's the proper way to filter for value within a (custom) attribute list?
Currently I'm trying to do as following...
...which doesn't work out since API returns BadRequest:
Any ideas?
Using version 1.1.3 of commercetools.Sdk.All.