From fd6c2aec01b2f8554dcc4929c1ce353c226436a8 Mon Sep 17 00:00:00 2001 From: Christopher Jolly Date: Mon, 3 Jul 2023 22:09:24 +0800 Subject: [PATCH] Revert ca0feb49 . Same name extensions when using sql server and jet --- .../Extensions/JetIndexBuilderExtensions.cs | 393 ------------------ .../Extensions/JetIndexExtensions.cs | 69 --- .../Extensions/JetKeyBuilderExtensions.cs | 101 ----- src/EFCore.Jet/Extensions/JetKeyExtensions.cs | 83 ---- .../Metadata/Internal/JetAnnotationNames.cs | 8 - 5 files changed, 654 deletions(-) delete mode 100644 src/EFCore.Jet/Extensions/JetIndexBuilderExtensions.cs delete mode 100644 src/EFCore.Jet/Extensions/JetKeyBuilderExtensions.cs delete mode 100644 src/EFCore.Jet/Extensions/JetKeyExtensions.cs diff --git a/src/EFCore.Jet/Extensions/JetIndexBuilderExtensions.cs b/src/EFCore.Jet/Extensions/JetIndexBuilderExtensions.cs deleted file mode 100644 index 69abd62..0000000 --- a/src/EFCore.Jet/Extensions/JetIndexBuilderExtensions.cs +++ /dev/null @@ -1,393 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq.Expressions; -using System.Linq; -using EntityFrameworkCore.Jet.Metadata.Internal; -using EntityFrameworkCore.Jet.Utilities; -using JetBrains.Annotations; -using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Metadata.Builders; -#nullable enable -// ReSharper disable once CheckNamespace -namespace Microsoft.EntityFrameworkCore -{ - /// - /// Extension methods for for Jet-specific metadata. - /// - public static class JetIndexBuilderExtensions - { - /// - /// Configures whether the index is clustered when targeting SQL Server. - /// - /// - /// See Modeling entity types and relationships, and - /// Accessing SQL Server and SQL Azure databases with EF Core - /// for more information and examples. - /// - /// The builder for the index being configured. - /// A value indicating whether the index is clustered. - /// A builder to further configure the index. - public static IndexBuilder IsClustered(this IndexBuilder indexBuilder, bool clustered = false) - { - indexBuilder.Metadata.SetIsClustered(clustered); - - return indexBuilder; - } - - /// - /// Configures whether the index is clustered when targeting SQL Server. - /// - /// - /// See Modeling entity types and relationships, and - /// Accessing SQL Server and SQL Azure databases with EF Core - /// for more information and examples. - /// - /// The builder for the index being configured. - /// A value indicating whether the index is clustered. - /// A builder to further configure the index. - public static IndexBuilder IsClustered( - this IndexBuilder indexBuilder, - bool clustered = false) - => (IndexBuilder)IsClustered((IndexBuilder)indexBuilder, clustered); - - /// - /// Configures whether the index is clustered when targeting SQL Server. - /// - /// - /// See Modeling entity types and relationships, and - /// Accessing SQL Server and SQL Azure databases with EF Core - /// for more information and examples. - /// - /// The builder for the index being configured. - /// A value indicating whether the index is clustered. - /// Indicates whether the configuration was specified using a data annotation. - /// - /// The same builder instance if the configuration was applied, - /// otherwise. - /// - public static IConventionIndexBuilder? IsClustered( - this IConventionIndexBuilder indexBuilder, - bool? clustered, - bool fromDataAnnotation = false) - { - if (indexBuilder.CanSetIsClustered(clustered, fromDataAnnotation)) - { - indexBuilder.Metadata.SetIsClustered(clustered, fromDataAnnotation); - return indexBuilder; - } - - return null; - } - - /// - /// Returns a value indicating whether the index can be configured as clustered. - /// - /// - /// See Modeling entity types and relationships, and - /// Accessing SQL Server and SQL Azure databases with EF Core - /// for more information and examples. - /// - /// The builder for the index being configured. - /// A value indicating whether the index is clustered. - /// Indicates whether the configuration was specified using a data annotation. - /// if the index can be configured as clustered. - public static bool CanSetIsClustered( - this IConventionIndexBuilder indexBuilder, - bool? clustered, - bool fromDataAnnotation = false) - => false; - - /// - /// Configures index include properties when targeting SQL Server. - /// - /// - /// See Modeling entity types and relationships, and - /// Accessing SQL Server and SQL Azure databases with EF Core - /// for more information and examples. - /// - /// The builder for the index being configured. - /// An array of property names to be used in 'include' clause. - /// A builder to further configure the index. - public static IndexBuilder IncludeProperties(this IndexBuilder indexBuilder, params string[] propertyNames) - { - Check.NotNull(propertyNames, nameof(propertyNames)); - - indexBuilder.Metadata.SetIncludeProperties(propertyNames); - - return indexBuilder; - } - - /// - /// Configures index include properties when targeting SQL Server. - /// - /// - /// See Modeling entity types and relationships, and - /// Accessing SQL Server and SQL Azure databases with EF Core - /// for more information and examples. - /// - /// The builder for the index being configured. - /// An array of property names to be used in 'include' clause. - /// A builder to further configure the index. - public static IndexBuilder IncludeProperties( - this IndexBuilder indexBuilder, - params string[] propertyNames) - { - Check.NotNull(propertyNames, nameof(propertyNames)); - - indexBuilder.Metadata.SetIncludeProperties(propertyNames); - - return indexBuilder; - } - - /// - /// Configures index include properties when targeting SQL Server. - /// - /// - /// See Modeling entity types and relationships, and - /// Accessing SQL Server and SQL Azure databases with EF Core - /// for more information and examples. - /// - /// The builder for the index being configured. - /// - /// - /// A lambda expression representing the property(s) to be included in the 'include' clause - /// (blog => blog.Url). - /// - /// - /// If multiple properties are to be included then specify an anonymous type including the - /// properties (post => new { post.Title, post.BlogId }). - /// - /// - /// A builder to further configure the index. - public static IndexBuilder IncludeProperties( - this IndexBuilder indexBuilder, - Expression> includeExpression) - { - Check.NotNull(includeExpression, nameof(includeExpression)); - - //IncludeProperties( - // indexBuilder, - // includeExpression.GetMemberAccessList().Select(EntityFrameworkMemberInfoExtensions.GetSimpleMemberName).ToArray()); - - return indexBuilder; - } - - /// - /// Configures index include properties when targeting SQL Server. - /// - /// - /// See Modeling entity types and relationships, and - /// Accessing SQL Server and SQL Azure databases with EF Core - /// for more information and examples. - /// - /// The builder for the index being configured. - /// An array of property names to be used in 'include' clause. - /// Indicates whether the configuration was specified using a data annotation. - /// - /// The same builder instance if the configuration was applied, - /// otherwise. - /// - public static IConventionIndexBuilder? IncludeProperties( - this IConventionIndexBuilder indexBuilder, - IReadOnlyList propertyNames, - bool fromDataAnnotation = false) - { - if (indexBuilder.CanSetIncludeProperties(propertyNames, fromDataAnnotation)) - { - indexBuilder.Metadata.SetIncludeProperties(propertyNames, fromDataAnnotation); - - return indexBuilder; - } - - return null; - } - - /// - /// Returns a value indicating whether the given include properties can be set. - /// - /// - /// See Modeling entity types and relationships, and - /// Accessing SQL Server and SQL Azure databases with EF Core - /// for more information and examples. - /// - /// The builder for the index being configured. - /// An array of property names to be used in 'include' clause. - /// Indicates whether the configuration was specified using a data annotation. - /// if the given include properties can be set. - public static bool CanSetIncludeProperties( - this IConventionIndexBuilder indexBuilder, - IReadOnlyList? propertyNames, - bool fromDataAnnotation = false) - => false; - - /// - /// Configures whether the index is created with online option when targeting SQL Server. - /// - /// - /// See Modeling entity types and relationships, and - /// Accessing SQL Server and SQL Azure databases with EF Core - /// for more information and examples. - /// - /// The builder for the index being configured. - /// A value indicating whether the index is created with online option. - /// A builder to further configure the index. - public static IndexBuilder IsCreatedOnline(this IndexBuilder indexBuilder, bool createdOnline = true) - { - //indexBuilder.Metadata.SetIsCreatedOnline(createdOnline); - - return indexBuilder; - } - - /// - /// Configures whether the index is created with online option when targeting SQL Server. - /// - /// - /// See Modeling entity types and relationships, and - /// Accessing SQL Server and SQL Azure databases with EF Core - /// for more information and examples. - /// - /// The builder for the index being configured. - /// A value indicating whether the index is created with online option. - /// A builder to further configure the index. - public static IndexBuilder IsCreatedOnline( - this IndexBuilder indexBuilder, - bool createdOnline = true) - => (IndexBuilder)IsCreatedOnline((IndexBuilder)indexBuilder, createdOnline); - - /// - /// Configures whether the index is created with online option when targeting SQL Server. - /// - /// - /// See Modeling entity types and relationships, and - /// Accessing SQL Server and SQL Azure databases with EF Core - /// for more information and examples. - /// - /// The builder for the index being configured. - /// A value indicating whether the index is created with online option. - /// Indicates whether the configuration was specified using a data annotation. - /// - /// The same builder instance if the configuration was applied, - /// otherwise. - /// - public static IConventionIndexBuilder? IsCreatedOnline( - this IConventionIndexBuilder indexBuilder, - bool? createdOnline, - bool fromDataAnnotation = false) - { - if (indexBuilder.CanSetIsCreatedOnline(createdOnline, fromDataAnnotation)) - { - //indexBuilder.Metadata.SetIsCreatedOnline(createdOnline, fromDataAnnotation); - - return indexBuilder; - } - - return null; - } - - /// - /// Returns a value indicating whether the index can be configured with online option when targeting SQL Server. - /// - /// - /// See Modeling entity types and relationships, and - /// Accessing SQL Server and SQL Azure databases with EF Core - /// for more information and examples. - /// - /// The builder for the index being configured. - /// A value indicating whether the index is created with online option. - /// Indicates whether the configuration was specified using a data annotation. - /// - /// The same builder instance if the configuration was applied, - /// otherwise. - /// - /// if the index can be configured with online option when targeting SQL Server. - public static bool CanSetIsCreatedOnline( - this IConventionIndexBuilder indexBuilder, - bool? createdOnline, - bool fromDataAnnotation = false) - => false; - - /// - /// Configures whether the index is created with fill factor option when targeting SQL Server. - /// - /// - /// See Modeling entity types and relationships, and - /// Accessing SQL Server and SQL Azure databases with EF Core - /// for more information and examples. - /// - /// The builder for the index being configured. - /// A value indicating whether the index is created with fill factor option. - /// A builder to further configure the index. - public static IndexBuilder HasFillFactor(this IndexBuilder indexBuilder, int fillFactor) - { - //indexBuilder.Metadata.SetFillFactor(fillFactor); - - return indexBuilder; - } - - /// - /// Configures whether the index is created with fill factor option when targeting SQL Server. - /// - /// - /// See Modeling entity types and relationships, and - /// Accessing SQL Server and SQL Azure databases with EF Core - /// for more information and examples. - /// - /// The builder for the index being configured. - /// A value indicating whether the index is created with fill factor option. - /// A builder to further configure the index. - public static IndexBuilder HasFillFactor( - this IndexBuilder indexBuilder, - int fillFactor) - => (IndexBuilder)HasFillFactor((IndexBuilder)indexBuilder, fillFactor); - - /// - /// Configures whether the index is created with fill factor option when targeting SQL Server. - /// - /// - /// See Modeling entity types and relationships, and - /// Accessing SQL Server and SQL Azure databases with EF Core - /// for more information and examples. - /// - /// The builder for the index being configured. - /// A value indicating whether the index is created with fill factor option. - /// Indicates whether the configuration was specified using a data annotation. - /// - /// The same builder instance if the configuration was applied, - /// otherwise. - /// - public static IConventionIndexBuilder? HasFillFactor( - this IConventionIndexBuilder indexBuilder, - int? fillFactor, - bool fromDataAnnotation = false) - { - if (indexBuilder.CanSetFillFactor(fillFactor, fromDataAnnotation)) - { - //indexBuilder.Metadata.SetFillFactor(fillFactor, fromDataAnnotation); - - return indexBuilder; - } - - return null; - } - - /// - /// Returns a value indicating whether the index can be configured with fill factor option when targeting SQL Server. - /// - /// - /// See Modeling entity types and relationships, and - /// Accessing SQL Server and SQL Azure databases with EF Core - /// for more information and examples. - /// - /// The builder for the index being configured. - /// A value indicating whether the index is created with fill factor option. - /// Indicates whether the configuration was specified using a data annotation. - /// if the index can be configured with fill factor option when targeting SQL Server. - public static bool CanSetFillFactor( - this IConventionIndexBuilder indexBuilder, - int? fillFactor, - bool fromDataAnnotation = false) - => false; - } -} \ No newline at end of file diff --git a/src/EFCore.Jet/Extensions/JetIndexExtensions.cs b/src/EFCore.Jet/Extensions/JetIndexExtensions.cs index 30397b5..d2cd0a2 100644 --- a/src/EFCore.Jet/Extensions/JetIndexExtensions.cs +++ b/src/EFCore.Jet/Extensions/JetIndexExtensions.cs @@ -1,8 +1,6 @@ -using System; using System.Collections.Generic; using EntityFrameworkCore.Jet.Metadata.Internal; using JetBrains.Annotations; -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Metadata; // ReSharper disable once CheckNamespace @@ -13,73 +11,6 @@ namespace Microsoft.EntityFrameworkCore /// public static class JetIndexExtensions { - /// - /// Returns a value indicating whether the index is clustered. - /// - /// The index. - /// if the index is clustered. - public static bool? IsClustered(this IReadOnlyIndex index) - => (index is RuntimeIndex) - ? throw new InvalidOperationException(CoreStrings.RuntimeModelMissingData) - : (bool?)index[JetAnnotationNames.Clustered]; - - /// - /// Returns a value indicating whether the index is clustered. - /// - /// The index. - /// The identifier of the store object. - /// if the index is clustered. - public static bool? IsClustered(this IReadOnlyIndex index, in StoreObjectIdentifier storeObject) - { - if (index is RuntimeIndex) - { - throw new InvalidOperationException(CoreStrings.RuntimeModelMissingData); - } - - var annotation = index.FindAnnotation(JetAnnotationNames.Clustered); - if (annotation != null) - { - return (bool?)annotation.Value; - } - - var sharedTableRootIndex = index.FindSharedObjectRootIndex(storeObject); - return sharedTableRootIndex?.IsClustered(storeObject); - } - - /// - /// Sets a value indicating whether the index is clustered. - /// - /// The value to set. - /// The index. - public static void SetIsClustered(this IMutableIndex index, bool? value) - => index.SetAnnotation( - JetAnnotationNames.Clustered, - value); - - /// - /// Sets a value indicating whether the index is clustered. - /// - /// The value to set. - /// The index. - /// Indicates whether the configuration was specified using a data annotation. - /// The configured value. - public static bool? SetIsClustered( - this IConventionIndex index, - bool? value, - bool fromDataAnnotation = false) - => (bool?)index.SetAnnotation( - JetAnnotationNames.Clustered, - value, - fromDataAnnotation)?.Value; - - /// - /// Returns the for whether the index is clustered. - /// - /// The property. - /// The for whether the index is clustered. - public static ConfigurationSource? GetIsClusteredConfigurationSource(this IConventionIndex property) - => property.FindAnnotation(JetAnnotationNames.Clustered)?.GetConfigurationSource(); - /// /// Returns included property names, or null if they have not been specified. /// diff --git a/src/EFCore.Jet/Extensions/JetKeyBuilderExtensions.cs b/src/EFCore.Jet/Extensions/JetKeyBuilderExtensions.cs deleted file mode 100644 index 3368c0c..0000000 --- a/src/EFCore.Jet/Extensions/JetKeyBuilderExtensions.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq.Expressions; -using System.Linq; -using EntityFrameworkCore.Jet.Metadata.Internal; -using EntityFrameworkCore.Jet.Utilities; -using JetBrains.Annotations; -using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Metadata.Builders; -#nullable enable -// ReSharper disable once CheckNamespace -namespace Microsoft.EntityFrameworkCore -{ - /// - /// Extension methods for for Jet-specific metadata. - /// - public static class JetKeyBuilderExtensions - { - /// - /// Configures whether the key is clustered when targeting SQL Server. - /// - /// - /// See Modeling entity types and relationships, and - /// Accessing SQL Server and SQL Azure databases with EF Core - /// for more information and examples. - /// - /// The builder for the key being configured. - /// A value indicating whether the key is clustered. - /// The same builder instance so that multiple calls can be chained. - public static KeyBuilder IsClustered(this KeyBuilder keyBuilder, bool clustered = true) - { - keyBuilder.Metadata.SetIsClustered(clustered); - - return keyBuilder; - } - - /// - /// Configures whether the key is clustered when targeting SQL Server. - /// - /// - /// See Modeling entity types and relationships, and - /// Accessing SQL Server and SQL Azure databases with EF Core - /// for more information and examples. - /// - /// The builder for the key being configured. - /// A value indicating whether the key is clustered. - /// The same builder instance so that multiple calls can be chained. - public static KeyBuilder IsClustered( - this KeyBuilder keyBuilder, - bool clustered = true) - => (KeyBuilder)IsClustered((KeyBuilder)keyBuilder, clustered); - - /// - /// Configures whether the key is clustered when targeting SQL Server. - /// - /// - /// See Modeling entity types and relationships, and - /// Accessing SQL Server and SQL Azure databases with EF Core - /// for more information and examples. - /// - /// The builder for the key being configured. - /// A value indicating whether the key is clustered. - /// Indicates whether the configuration was specified using a data annotation. - /// - /// The same builder instance if the configuration was applied, - /// otherwise. - /// - public static IConventionKeyBuilder? IsClustered( - this IConventionKeyBuilder keyBuilder, - bool? clustered, - bool fromDataAnnotation = false) - { - if (keyBuilder.CanSetIsClustered(clustered, fromDataAnnotation)) - { - keyBuilder.Metadata.SetIsClustered(clustered, fromDataAnnotation); - return keyBuilder; - } - - return null; - } - - /// - /// Returns a value indicating whether the key can be configured as clustered. - /// - /// - /// See Modeling entity types and relationships, and - /// Accessing SQL Server and SQL Azure databases with EF Core - /// for more information and examples. - /// - /// The builder for the key being configured. - /// A value indicating whether the key is clustered. - /// Indicates whether the configuration was specified using a data annotation. - /// if the key can be configured as clustered. - public static bool CanSetIsClustered( - this IConventionKeyBuilder keyBuilder, - bool? clustered, - bool fromDataAnnotation = false) - => keyBuilder.CanSetAnnotation(JetAnnotationNames.Clustered, clustered, fromDataAnnotation); - } -} \ No newline at end of file diff --git a/src/EFCore.Jet/Extensions/JetKeyExtensions.cs b/src/EFCore.Jet/Extensions/JetKeyExtensions.cs deleted file mode 100644 index eadbfe9..0000000 --- a/src/EFCore.Jet/Extensions/JetKeyExtensions.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System; -using System.Collections.Generic; -using EntityFrameworkCore.Jet.Metadata.Internal; -using JetBrains.Annotations; -using Microsoft.EntityFrameworkCore.Diagnostics; -using Microsoft.EntityFrameworkCore.Metadata; - -// ReSharper disable once CheckNamespace -namespace Microsoft.EntityFrameworkCore -{ - /// - /// Key extension methods for SQL Server-specific metadata. - /// - public static class JetKeyExtensions - { - /// - /// Returns a value indicating whether the key is clustered. - /// - /// The key. - /// if the key is clustered. - public static bool? IsClustered(this IReadOnlyKey key) - => (key is RuntimeKey) - ? throw new InvalidOperationException(CoreStrings.RuntimeModelMissingData) - : (bool?)key[JetAnnotationNames.Clustered]; - - /// - /// Returns a value indicating whether the key is clustered. - /// - /// The key. - /// The identifier of the store object. - /// if the key is clustered. - public static bool? IsClustered(this IReadOnlyKey key, in StoreObjectIdentifier storeObject) - { - if (key is RuntimeKey) - { - throw new InvalidOperationException(CoreStrings.RuntimeModelMissingData); - } - - var annotation = key.FindAnnotation(JetAnnotationNames.Clustered); - if (annotation != null) - { - return (bool?)annotation.Value; - } - - return GetDefaultIsClustered(key, storeObject); - } - - private static bool? GetDefaultIsClustered(IReadOnlyKey key, in StoreObjectIdentifier storeObject) - { - var sharedTableRootKey = key.FindSharedObjectRootKey(storeObject); - return sharedTableRootKey?.IsClustered(storeObject); - } - - /// - /// Sets a value indicating whether the key is clustered. - /// - /// The key. - /// The value to set. - public static void SetIsClustered(this IMutableKey key, bool? clustered) - => key.SetOrRemoveAnnotation(JetAnnotationNames.Clustered, clustered); - - /// - /// Sets a value indicating whether the key is clustered. - /// - /// The key. - /// The value to set. - /// Indicates whether the configuration was specified using a data annotation. - /// The configured value. - public static bool? SetIsClustered(this IConventionKey key, bool? clustered, bool fromDataAnnotation = false) - => (bool?)key.SetOrRemoveAnnotation( - JetAnnotationNames.Clustered, - clustered, - fromDataAnnotation)?.Value; - - /// - /// Gets the for whether the key is clustered. - /// - /// The key. - /// The for whether the key is clustered. - public static ConfigurationSource? GetIsClusteredConfigurationSource(this IConventionKey key) - => key.FindAnnotation(JetAnnotationNames.Clustered)?.GetConfigurationSource(); - } -} \ No newline at end of file diff --git a/src/EFCore.Jet/Metadata/Internal/JetAnnotationNames.cs b/src/EFCore.Jet/Metadata/Internal/JetAnnotationNames.cs index baffc75..a5f97db 100644 --- a/src/EFCore.Jet/Metadata/Internal/JetAnnotationNames.cs +++ b/src/EFCore.Jet/Metadata/Internal/JetAnnotationNames.cs @@ -18,14 +18,6 @@ namespace EntityFrameworkCore.Jet.Metadata.Internal /// public const string Prefix = "Jet:"; - /// - /// 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 const string Clustered = Prefix + "Clustered"; - /// /// 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