Skip to content

Commit 8393599

Browse files
committed
initial commit
1 parent 17bbdab commit 8393599

6 files changed

+24
-16
lines changed

Microsoft.Azure.Cosmos/src/Linq/DefaultCosmosLinqSerializer.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace Microsoft.Azure.Cosmos.Linq
1111
using System.Runtime.Serialization;
1212
using Microsoft.Azure.Documents;
1313
using Newtonsoft.Json;
14+
using Newtonsoft.Json.Serialization;
1415

1516
internal class DefaultCosmosLinqSerializer : ICosmosLinqSerializerInternal
1617
{
@@ -67,7 +68,14 @@ public string Serialize(object value, MemberExpression memberExpression, Type me
6768

6869
public string SerializeScalarExpression(ConstantExpression inputExpression)
6970
{
70-
return JsonConvert.SerializeObject(inputExpression.Value);
71+
JsonSerializerSettings settings = this.PropertyNamingPolicy == CosmosPropertyNamingPolicy.CamelCase
72+
? new JsonSerializerSettings
73+
{
74+
ContractResolver = new CamelCasePropertyNamesContractResolver()
75+
}
76+
: new JsonSerializerSettings();
77+
78+
return JsonConvert.SerializeObject(inputExpression.Value, settings);
7179
}
7280

7381
public string SerializeMemberName(MemberInfo memberInfo)

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/LinqTranslationWithCustomSerializerBaseline.TestMemberInitializerDataMember.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ WHERE (root["numericFieldDataMember"] = 1)]]></SqlQuery>
2929
<SqlQuery><![CDATA[
3030
SELECT VALUE root
3131
FROM root
32-
WHERE (root = {"NumericFieldDataMember": 1, "StringFieldDataMember": "1", "id": null, "Pk": null})]]></SqlQuery>
32+
WHERE (root = {"numericFieldDataMember": 1, "stringFieldDataMember": "1", "id": null, "pk": null})]]></SqlQuery>
3333
<InputData><![CDATA[[
3434
"{\"NumericField\": 0, \"StringField\": \"0\", \"id\": \"0-True\", \"Pk\": \"Test\"}",
3535
"{\"NumericField\": 1, \"StringField\": \"1\", \"id\": \"1-True\", \"Pk\": \"Test\"}",
@@ -48,7 +48,7 @@ WHERE (root = {"NumericFieldDataMember": 1, "StringFieldDataMember": "1", "id":
4848
</Input>
4949
<Output>
5050
<SqlQuery><![CDATA[
51-
SELECT VALUE {"NumericFieldDataMember": 1, "StringFieldDataMember": "1", "id": null, "Pk": null}
51+
SELECT VALUE {"numericFieldDataMember": 1, "stringFieldDataMember": "1", "id": null, "pk": null}
5252
FROM root]]></SqlQuery>
5353
<InputData><![CDATA[[
5454
"{\"NumericField\": 0, \"StringField\": \"0\", \"id\": \"0-True\", \"Pk\": \"Test\"}",
@@ -75,7 +75,7 @@ FROM root]]></SqlQuery>
7575
</Input>
7676
<Output>
7777
<SqlQuery><![CDATA[
78-
SELECT VALUE ((root["numericFieldDataMember"] > 1) ? {"NumericFieldDataMember": 1, "StringFieldDataMember": "1", "id": null, "Pk": null} : {"NumericFieldDataMember": 1, "StringFieldDataMember": "1", "id": null, "Pk": null})
78+
SELECT VALUE ((root["numericFieldDataMember"] > 1) ? {"numericFieldDataMember": 1, "stringFieldDataMember": "1", "id": null, "pk": null} : {"numericFieldDataMember": 1, "stringFieldDataMember": "1", "id": null, "pk": null})
7979
FROM root]]></SqlQuery>
8080
<InputData><![CDATA[[
8181
"{\"NumericField\": 0, \"StringField\": \"0\", \"id\": \"0-True\", \"Pk\": \"Test\"}",

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/LinqTranslationWithCustomSerializerBaseline.TestMemberInitializerDotNetDataMember.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ WHERE (root["numericFieldDataMember"] = 1)]]></SqlQuery>
2929
<SqlQuery><![CDATA[
3030
SELECT VALUE root
3131
FROM root
32-
WHERE (root = {"NumericFieldDataMember": 1, "StringFieldDataMember": "1"})]]></SqlQuery>
32+
WHERE (root = {"numericFieldDataMember": 1, "stringFieldDataMember": "1"})]]></SqlQuery>
3333
<InputData><![CDATA[[
3434
"{\"numberValueDotNet\": 0, \"stringValueDotNet\": \"0\", \"id\": \"0-True\", \"Pk\": \"Test\"}",
3535
"{\"numberValueDotNet\": 1, \"stringValueDotNet\": \"1\", \"id\": \"1-True\", \"Pk\": \"Test\"}",
@@ -48,7 +48,7 @@ WHERE (root = {"NumericFieldDataMember": 1, "StringFieldDataMember": "1"})]]></S
4848
</Input>
4949
<Output>
5050
<SqlQuery><![CDATA[
51-
SELECT VALUE {"NumericFieldDataMember": 1, "StringFieldDataMember": "1"}
51+
SELECT VALUE {"numericFieldDataMember": 1, "stringFieldDataMember": "1"}
5252
FROM root]]></SqlQuery>
5353
<InputData><![CDATA[[
5454
"{\"numberValueDotNet\": 0, \"stringValueDotNet\": \"0\", \"id\": \"0-True\", \"Pk\": \"Test\"}",
@@ -75,7 +75,7 @@ FROM root]]></SqlQuery>
7575
</Input>
7676
<Output>
7777
<SqlQuery><![CDATA[
78-
SELECT VALUE ((root["numericFieldDataMember"] > 1) ? {"NumericFieldDataMember": 1, "StringFieldDataMember": "1"} : {"NumericFieldDataMember": 1, "StringFieldDataMember": "1"})
78+
SELECT VALUE ((root["numericFieldDataMember"] > 1) ? {"numericFieldDataMember": 1, "stringFieldDataMember": "1"} : {"numericFieldDataMember": 1, "stringFieldDataMember": "1"})
7979
FROM root]]></SqlQuery>
8080
<InputData><![CDATA[[
8181
"{\"numberValueDotNet\": 0, \"stringValueDotNet\": \"0\", \"id\": \"0-True\", \"Pk\": \"Test\"}",

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/LinqTranslationWithCustomSerializerBaseline.TestMemberInitializerNewtonsoft.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ WHERE (root["numberValueNewtonsoft"] = 1)]]></SqlQuery>
2929
<SqlQuery><![CDATA[
3030
SELECT VALUE root
3131
FROM root
32-
WHERE (root = {"NumberValueNewtonsoft": 1, "StringValueNewtonsoft": "1", "id": null, "Pk": null})]]></SqlQuery>
32+
WHERE (root = {"numberValueNewtonsoft": 1, "stringValueNewtonsoft": "1", "id": null, "pk": null})]]></SqlQuery>
3333
<InputData><![CDATA[[
3434
"{\"NumericField\": 0, \"StringField\": \"0\", \"IgnoreField\": \"ignore\", \"id\": \"0-True\"}",
3535
"{\"NumericField\": 1, \"StringField\": \"1\", \"IgnoreField\": \"ignore\", \"id\": \"1-True\"}",
@@ -48,7 +48,7 @@ WHERE (root = {"NumberValueNewtonsoft": 1, "StringValueNewtonsoft": "1", "id": n
4848
</Input>
4949
<Output>
5050
<SqlQuery><![CDATA[
51-
SELECT VALUE {"NumberValueNewtonsoft": 1, "StringValueNewtonsoft": "1", "id": null, "Pk": null}
51+
SELECT VALUE {"numberValueNewtonsoft": 1, "stringValueNewtonsoft": "1", "id": null, "pk": null}
5252
FROM root]]></SqlQuery>
5353
<InputData><![CDATA[[
5454
"{\"NumericField\": 0, \"StringField\": \"0\", \"IgnoreField\": \"ignore\", \"id\": \"0-True\"}",
@@ -75,7 +75,7 @@ FROM root]]></SqlQuery>
7575
</Input>
7676
<Output>
7777
<SqlQuery><![CDATA[
78-
SELECT VALUE ((root["numberValueNewtonsoft"] > 1) ? {"NumberValueNewtonsoft": 1, "StringValueNewtonsoft": "1", "id": null, "Pk": null} : {"NumberValueNewtonsoft": 1, "StringValueNewtonsoft": "1", "id": null, "Pk": null})
78+
SELECT VALUE ((root["numberValueNewtonsoft"] > 1) ? {"numberValueNewtonsoft": 1, "stringValueNewtonsoft": "1", "id": null, "pk": null} : {"numberValueNewtonsoft": 1, "stringValueNewtonsoft": "1", "id": null, "pk": null})
7979
FROM root]]></SqlQuery>
8080
<InputData><![CDATA[[
8181
"{\"NumericField\": 0, \"StringField\": \"0\", \"IgnoreField\": \"ignore\", \"id\": \"0-True\"}",

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/LinqTranslationWithCustomSerializerBaseline.TestMemberInitializerNewtonsoftDataMember.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ WHERE (root["numberValueNewtonsoft"] = 1)]]></SqlQuery>
2929
<SqlQuery><![CDATA[
3030
SELECT VALUE root
3131
FROM root
32-
WHERE (root = {"NumberValueNewtonsoft": 1, "StringValueNewtonsoft": "1"})]]></SqlQuery>
32+
WHERE (root = {"numberValueNewtonsoft": 1, "stringValueNewtonsoft": "1"})]]></SqlQuery>
3333
<InputData><![CDATA[[
3434
"{\"NumericField\": 0, \"StringField\": \"0\", \"id\": \"0-True\", \"Pk\": \"Test\"}",
3535
"{\"NumericField\": 1, \"StringField\": \"1\", \"id\": \"1-True\", \"Pk\": \"Test\"}",
@@ -48,7 +48,7 @@ WHERE (root = {"NumberValueNewtonsoft": 1, "StringValueNewtonsoft": "1"})]]></Sq
4848
</Input>
4949
<Output>
5050
<SqlQuery><![CDATA[
51-
SELECT VALUE {"NumberValueNewtonsoft": 1, "StringValueNewtonsoft": "1"}
51+
SELECT VALUE {"numberValueNewtonsoft": 1, "stringValueNewtonsoft": "1"}
5252
FROM root]]></SqlQuery>
5353
<InputData><![CDATA[[
5454
"{\"NumericField\": 0, \"StringField\": \"0\", \"id\": \"0-True\", \"Pk\": \"Test\"}",
@@ -75,7 +75,7 @@ FROM root]]></SqlQuery>
7575
</Input>
7676
<Output>
7777
<SqlQuery><![CDATA[
78-
SELECT VALUE ((root["numberValueNewtonsoft"] > 1) ? {"NumberValueNewtonsoft": 1, "StringValueNewtonsoft": "1"} : {"NumberValueNewtonsoft": 1, "StringValueNewtonsoft": "1"})
78+
SELECT VALUE ((root["numberValueNewtonsoft"] > 1) ? {"numberValueNewtonsoft": 1, "stringValueNewtonsoft": "1"} : {"numberValueNewtonsoft": 1, "stringValueNewtonsoft": "1"})
7979
FROM root]]></SqlQuery>
8080
<InputData><![CDATA[[
8181
"{\"NumericField\": 0, \"StringField\": \"0\", \"id\": \"0-True\", \"Pk\": \"Test\"}",

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/LinqTranslationWithCustomSerializerBaseline.TestMemberInitializerNewtonsoftDotNet.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ WHERE (root["numberValueNewtonsoft"] = 1)]]></SqlQuery>
2929
<SqlQuery><![CDATA[
3030
SELECT VALUE root
3131
FROM root
32-
WHERE (root = {"NumberValueNewtonsoft": 1, "StringValueNewtonsoft": "1", "id": null, "Pk": null})]]></SqlQuery>
32+
WHERE (root = {"numberValueNewtonsoft": 1, "stringValueNewtonsoft": "1", "id": null, "pk": null})]]></SqlQuery>
3333
<InputData><![CDATA[[
3434
"{\"numberValueDotNet\": 0, \"stringValueDotNet\": \"0\", \"id\": \"0-True\", \"Pk\": \"Test\"}",
3535
"{\"numberValueDotNet\": 1, \"stringValueDotNet\": \"1\", \"id\": \"1-True\", \"Pk\": \"Test\"}",
@@ -48,7 +48,7 @@ WHERE (root = {"NumberValueNewtonsoft": 1, "StringValueNewtonsoft": "1", "id": n
4848
</Input>
4949
<Output>
5050
<SqlQuery><![CDATA[
51-
SELECT VALUE {"NumberValueNewtonsoft": 1, "StringValueNewtonsoft": "1", "id": null, "Pk": null}
51+
SELECT VALUE {"numberValueNewtonsoft": 1, "stringValueNewtonsoft": "1", "id": null, "pk": null}
5252
FROM root]]></SqlQuery>
5353
<InputData><![CDATA[[
5454
"{\"numberValueDotNet\": 0, \"stringValueDotNet\": \"0\", \"id\": \"0-True\", \"Pk\": \"Test\"}",
@@ -75,7 +75,7 @@ FROM root]]></SqlQuery>
7575
</Input>
7676
<Output>
7777
<SqlQuery><![CDATA[
78-
SELECT VALUE ((root["numberValueNewtonsoft"] > 1) ? {"NumberValueNewtonsoft": 1, "StringValueNewtonsoft": "1", "id": null, "Pk": null} : {"NumberValueNewtonsoft": 1, "StringValueNewtonsoft": "1", "id": null, "Pk": null})
78+
SELECT VALUE ((root["numberValueNewtonsoft"] > 1) ? {"numberValueNewtonsoft": 1, "stringValueNewtonsoft": "1", "id": null, "pk": null} : {"numberValueNewtonsoft": 1, "stringValueNewtonsoft": "1", "id": null, "pk": null})
7979
FROM root]]></SqlQuery>
8080
<InputData><![CDATA[[
8181
"{\"numberValueDotNet\": 0, \"stringValueDotNet\": \"0\", \"id\": \"0-True\", \"Pk\": \"Test\"}",

0 commit comments

Comments
 (0)