You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added ArrayContains to CosmosLinqExtensions to allow partial matching
The `Array_Contains` funtion CosmosDB Sql has a 3rd parameter which allows it to do a partial match on the given item. This is unable to be called with the built in Linq `array.Contains(item)` extension methods.
This adds this adds an explicit mapping to this function to allow it to be called in Linq like this:
`documents.Where(document => document.ObjectArray.ArrayContains(new { Name = "abc" }, true))`
#pragma warning restore // Field is never assigned to, and will always have its default value false
122
123
@@ -343,6 +344,31 @@ public void TestRegexMatchFunction()
343
344
344
345
newLinqTestInput("RegexMatch with 2nd argument invalid string options", b =>getQuery(b).Where(doc =>doc.StringField.RegexMatch("abcd","this should error out on the back end"))),
345
346
};
347
+
this.ExecuteTestSuite(inputs);
348
+
}
349
+
350
+
[TestMethod]
351
+
publicvoidTestArrayContainsBuiltinFunction()
352
+
{
353
+
// Similar to the type checking function, Array_Contains are not supported client side.
354
+
// Therefore these methods are verified with baseline only.
newLinqTestInput("ArrayContains in Select clause with int value and match partial true", b =>getQuery(b).Select(doc =>doc.ArrayField.ArrayContains(1,true))),
362
+
newLinqTestInput("ArrayContains in Filter clause with int value and match partial true", b =>getQuery(b).Where(doc =>doc.ArrayField.ArrayContains(1,true))),
363
+
newLinqTestInput("ArrayContains in Select clause with object value and match partial true", b =>getQuery(b).Select(doc =>doc.ObjectArrayField.ArrayContains(new{Field="abc"},true))),
364
+
newLinqTestInput("ArrayContains in Filter clause with object value and match partial true", b =>getQuery(b).Where(doc =>doc.ObjectArrayField.ArrayContains(new{Field="abc"},true))),
365
+
366
+
newLinqTestInput("ArrayContains in Select clause with int value and match partial false", b =>getQuery(b).Select(doc =>doc.ArrayField.ArrayContains(1,false))),
367
+
newLinqTestInput("ArrayContains in Filter clause with int value and match partial false", b =>getQuery(b).Where(doc =>doc.ArrayField.ArrayContains(1,false))),
368
+
newLinqTestInput("ArrayContains in Select clause with object value and match partial false", b =>getQuery(b).Select(doc =>doc.ObjectArrayField.ArrayContains(new{Field="abc"},false))),
369
+
newLinqTestInput("ArrayContains in Filter clause with object value and match partial false", b =>getQuery(b).Where(doc =>doc.ObjectArrayField.ArrayContains(new{Field="abc"},false))),
370
+
};
371
+
346
372
this.ExecuteTestSuite(inputs);
347
373
}
348
374
@@ -449,10 +475,11 @@ public void TestDateTimeJsonConverter()
Copy file name to clipboardExpand all lines: Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Microsoft.Azure.Cosmos.EmulatorTests.csproj
0 commit comments