From 8bfaf8ad35c3fd5d194bcd37a90ca45bbd90d133 Mon Sep 17 00:00:00 2001 From: Alexander Fanat Date: Thu, 20 Aug 2020 08:46:57 -0700 Subject: [PATCH] Fix #18710 via proceeding with translation of non-persisted JObject property. --- .../Query/Internal/EntityProjectionExpression.cs | 1 + .../Storage/Internal/CosmosTypeMappingSource.cs | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/EFCore.Cosmos/Query/Internal/EntityProjectionExpression.cs b/src/EFCore.Cosmos/Query/Internal/EntityProjectionExpression.cs index fd7c02e182d..8a8a88adafd 100644 --- a/src/EFCore.Cosmos/Query/Internal/EntityProjectionExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/EntityProjectionExpression.cs @@ -128,6 +128,7 @@ public virtual Expression BindProperty([NotNull] IProperty property, bool client } if (!clientEval + && property.Name != EntityFrameworkCore.Metadata.Conventions.StoreKeyConvention.JObjectPropertyName && expression.Name.Length == 0) { // Non-persisted property can't be translated diff --git a/src/EFCore.Cosmos/Storage/Internal/CosmosTypeMappingSource.cs b/src/EFCore.Cosmos/Storage/Internal/CosmosTypeMappingSource.cs index 8ace7c1eab1..07fa2bada71 100644 --- a/src/EFCore.Cosmos/Storage/Internal/CosmosTypeMappingSource.cs +++ b/src/EFCore.Cosmos/Storage/Internal/CosmosTypeMappingSource.cs @@ -3,9 +3,13 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Linq.Expressions; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.Storage; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Utilities; using Newtonsoft.Json.Linq; @@ -33,7 +37,8 @@ public CosmosTypeMappingSource([NotNull] TypeMappingSourceDependencies dependenc _clrTypeMappings = new Dictionary { - { typeof(byte[]), new CosmosTypeMapping(typeof(byte[]), keyComparer: new ArrayStructuralComparer()) } + { typeof(byte[]), new CosmosTypeMapping(typeof(byte[]), keyComparer: new ArrayStructuralComparer()) }, + { typeof(JObject), new CosmosTypeMapping(typeof(JObject)) } }; }