diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosSerializationUtilities.cs b/src/EFCore.Cosmos/Query/Internal/CosmosSerializationUtilities.cs index 3bb327b2ed9..6e801bd93f4 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosSerializationUtilities.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosSerializationUtilities.cs @@ -3,7 +3,7 @@ using System.Collections; using Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal; -using Microsoft.EntityFrameworkCore.Update.Internal; +using Microsoft.EntityFrameworkCore.Metadata.Internal; using Newtonsoft.Json.Linq; namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal; diff --git a/src/EFCore/Metadata/Internal/PropertyExtensions.cs b/src/EFCore/Metadata/Internal/PropertyExtensions.cs index 2bbfb3bcceb..29603269565 100644 --- a/src/EFCore/Metadata/Internal/PropertyExtensions.cs +++ b/src/EFCore/Metadata/Internal/PropertyExtensions.cs @@ -173,4 +173,26 @@ public static bool RequiresOriginalValue(this IReadOnlyProperty property) /// public static bool RequiresOriginalValue(this IReadOnlyComplexProperty property) => property.ComplexType.ContainingEntityType.GetChangeTrackingStrategy() != ChangeTrackingStrategy.ChangingAndChangedNotifications; + + /// + /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to + /// the same compatibility standards as public APIs. It may be changed or removed without notice in + /// any release. You should only use it directly in your code with extreme caution and knowing that + /// doing so can result in application failures when updating to a new Entity Framework Core release. + /// + public static object? ConvertToProviderValue(this IProperty property, object? value) + { + var typeMapping = property.GetTypeMapping(); + value = value?.GetType().IsInteger() == true && typeMapping.ClrType.UnwrapNullableType().IsEnum + ? Enum.ToObject(typeMapping.ClrType.UnwrapNullableType(), value) + : value; + + var converter = typeMapping.Converter; + if (converter != null) + { + value = converter.ConvertToProvider(value); + } + + return value; + } } diff --git a/src/EFCore/Update/Internal/InternalUpdateEntryExtensions.cs b/src/EFCore/Update/Internal/InternalUpdateEntryExtensions.cs index aaba4ce641a..367d676a022 100644 --- a/src/EFCore/Update/Internal/InternalUpdateEntryExtensions.cs +++ b/src/EFCore/Update/Internal/InternalUpdateEntryExtensions.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.EntityFrameworkCore.ChangeTracking.Internal; +using Microsoft.EntityFrameworkCore.Metadata.Internal; namespace Microsoft.EntityFrameworkCore.Update.Internal; diff --git a/src/EFCore/Update/Internal/PropertyExtensions.cs b/src/EFCore/Update/Internal/PropertyExtensions.cs deleted file mode 100644 index 0f7cb3655ed..00000000000 --- a/src/EFCore/Update/Internal/PropertyExtensions.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.EntityFrameworkCore.Update.Internal; - -/// -/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to -/// the same compatibility standards as public APIs. It may be changed or removed without notice in -/// any release. You should only use it directly in your code with extreme caution and knowing that -/// doing so can result in application failures when updating to a new Entity Framework Core release. -/// -public static class PropertyExtensions -{ - /// - /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to - /// the same compatibility standards as public APIs. It may be changed or removed without notice in - /// any release. You should only use it directly in your code with extreme caution and knowing that - /// doing so can result in application failures when updating to a new Entity Framework Core release. - /// - public static object? ConvertToProviderValue(this IProperty property, object? value) - { - var typeMapping = property.GetTypeMapping(); - value = value?.GetType().IsInteger() == true && typeMapping.ClrType.UnwrapNullableType().IsEnum - ? Enum.ToObject(typeMapping.ClrType.UnwrapNullableType(), value) - : value; - - var converter = typeMapping.Converter; - if (converter != null) - { - value = converter.ConvertToProvider(value); - } - - return value; - } -}