Skip to content

Commit 270adac

Browse files
JoasEAndriySvyryd
authored andcommitted
Move PropertyExtensions from Update to Metadata
1 parent 8bf0f7f commit 270adac

4 files changed

Lines changed: 24 additions & 36 deletions

File tree

src/EFCore.Cosmos/Query/Internal/CosmosSerializationUtilities.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
using System.Collections;
55
using Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal;
6-
using Microsoft.EntityFrameworkCore.Update.Internal;
6+
using Microsoft.EntityFrameworkCore.Metadata.Internal;
77
using Newtonsoft.Json.Linq;
88

99
namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal;

src/EFCore/Metadata/Internal/PropertyExtensions.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,26 @@ public static bool RequiresOriginalValue(this IReadOnlyProperty property)
173173
/// </summary>
174174
public static bool RequiresOriginalValue(this IReadOnlyComplexProperty property)
175175
=> property.ComplexType.ContainingEntityType.GetChangeTrackingStrategy() != ChangeTrackingStrategy.ChangingAndChangedNotifications;
176+
177+
/// <summary>
178+
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
179+
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
180+
/// any release. You should only use it directly in your code with extreme caution and knowing that
181+
/// doing so can result in application failures when updating to a new Entity Framework Core release.
182+
/// </summary>
183+
public static object? ConvertToProviderValue(this IProperty property, object? value)
184+
{
185+
var typeMapping = property.GetTypeMapping();
186+
value = value?.GetType().IsInteger() == true && typeMapping.ClrType.UnwrapNullableType().IsEnum
187+
? Enum.ToObject(typeMapping.ClrType.UnwrapNullableType(), value)
188+
: value;
189+
190+
var converter = typeMapping.Converter;
191+
if (converter != null)
192+
{
193+
value = converter.ConvertToProvider(value);
194+
}
195+
196+
return value;
197+
}
176198
}

src/EFCore/Update/Internal/InternalUpdateEntryExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using Microsoft.EntityFrameworkCore.ChangeTracking.Internal;
5+
using Microsoft.EntityFrameworkCore.Metadata.Internal;
56

67
namespace Microsoft.EntityFrameworkCore.Update.Internal;
78

src/EFCore/Update/Internal/PropertyExtensions.cs

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)