As part of #31046, NewArrayExpression no longer gets client-evaluated to a single array parameter; this allows us to translate e.g. new[] { i, j } to IN (@i, @j). Full translation support for NewArrayExpression has been implemented in relational (as VALUES (...), which gets transformed to IN if Contains is composed on top); but Cosmos support hasn't been done.
As a result, Cosmos queries which include parameters fail translation; see test Array_of_parameters_Contains_OrElse_comparison_with_constant_gets_combined_to_one_in:
var prm1 = "ALFKI";
var prm2 = "ANATR";
return AssertQuery(
async,
ss => ss.Set<Customer>().Where(c => new[] { prm1, prm2 }.Contains(c.CustomerID) || c.CustomerID == "ANTON"),
entryCount: 3);
We can implement support for this in the Cosmos query pipeline, and there's some potential for Cosmos-specific translations around the area as well. In the meantime, the workaround is to extract the inline array:
var array = new[] { "ALFKI", "ANATR" };
return AssertQuery(
async,
ss => ss.Set<Customer>().Where(c => array.Contains(c.CustomerID) || c.CustomerID == "ANTON"),
entryCount: 3);
As part of #31046, NewArrayExpression no longer gets client-evaluated to a single array parameter; this allows us to translate e.g.
new[] { i, j }toIN (@i, @j). Full translation support for NewArrayExpression has been implemented in relational (asVALUES (...), which gets transformed to IN if Contains is composed on top); but Cosmos support hasn't been done.As a result, Cosmos queries which include parameters fail translation; see test Array_of_parameters_Contains_OrElse_comparison_with_constant_gets_combined_to_one_in:
We can implement support for this in the Cosmos query pipeline, and there's some potential for Cosmos-specific translations around the area as well. In the meantime, the workaround is to extract the inline array: