Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Maya-Painter committed Oct 26, 2024
1 parent ed75a42 commit 6ef9843
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Microsoft.Azure.Cosmos.Linq
{
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq.Expressions;
using Microsoft.Azure.Cosmos;
Expand Down Expand Up @@ -97,7 +96,7 @@ public static SqlScalarExpression VisitBuiltinFunctionCall(MethodCallExpression
}

// Array functions
if (declaringType.IsEnumerable())
if (declaringType.IsEnumerable() || declaringType == typeof(System.Text.Json.Nodes.JsonNode))
{
return ArrayBuiltinFunctions.Visit(methodCallExpression, context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests
using Microsoft.Azure.Cosmos.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Linq.Dynamic;
using System.Linq.Expressions;
using System.Text.Json.Nodes;
using System.Threading.Tasks;

[TestClass]
Expand Down Expand Up @@ -949,6 +951,22 @@ public async Task LinqSelectEverythingWithoutQueryableTest()
Assert.AreEqual(2, (await this.FetchResults<ToDoActivity>(queryDefinition)).Count);
}

[TestMethod]
public async Task LinqJsonObjectTest()
{
await ToDoActivity.CreateRandomItems(this.Container, pkCount: 2, perPKItemCount: 1, randomPartitionKey: true);

IOrderedQueryable<JObject> queryableJObject = this.Container.GetItemLinqQueryable<JObject>();
IQueryable<JObject> queryJObject = queryableJObject.Where(f => (string)f["id"] == "fooBar");
string queryTextJObject = queryJObject.ToString();

IOrderedQueryable<JsonObject> queryableJsonObject = this.Container.GetItemLinqQueryable<JsonObject>();
IQueryable<JsonObject> queryJsonObject = queryableJsonObject.Where(f => (string)f["id"] == "fooBar");
string queryTextJsonObject = queryJsonObject.ToString();

Assert.AreEqual(queryTextJObject, queryTextJsonObject);
}

private class NumberLinqItem
{
public string id;
Expand Down

0 comments on commit 6ef9843

Please sign in to comment.