From c6be6901c09e9e6c437d35c64a4027022b1ccf91 Mon Sep 17 00:00:00 2001 From: Arthur Vickers Date: Sun, 23 Aug 2020 11:47:26 -0700 Subject: [PATCH] Code cleanup for database providers --- .../Diagnostics/CosmosEventId.cs | 4 +- .../CosmosDbContextOptionsExtensions.cs | 4 +- .../CosmosEntityTypeBuilderExtensions.cs | 12 +- .../Extensions/CosmosEntityTypeExtensions.cs | 34 +++-- .../Extensions/CosmosModelExtensions.cs | 4 +- .../Extensions/CosmosPropertyExtensions.cs | 10 +- .../Extensions/CosmosQueryableExtensions.cs | 2 +- .../CosmosDbContextOptionsBuilder.cs | 13 +- .../Internal/CosmosDbOptionExtension.cs | 56 ++++--- .../Internal/CosmosSingletonOptions.cs | 1 - .../Internal/ICosmosSingletonOptions.cs | 2 +- .../Internal/CosmosModelValidator.cs | 20 ++- .../Conventions/StoreKeyConvention.cs | 2 +- .../Internal/CosmosEntityTypeExtensions.cs | 4 +- .../Internal/CosmosNavigationExtensions.cs | 2 +- .../Internal/CosmosPropertyExtensions.cs | 3 +- .../Query/Internal/ContainsTranslator.cs | 5 +- .../CosmosMemberTranslatorProvider.cs | 5 +- .../CosmosMethodCallTranslatorProvider.cs | 5 +- ...osmosProjectionBindingExpressionVisitor.cs | 16 +- .../Internal/CosmosQueryCompilationContext.cs | 3 +- ...ueryMetadataExtractingExpressionVisitor.cs | 3 +- ...smosQueryTranslationPreprocessorFactory.cs | 2 +- ...yableMethodTranslatingExpressionVisitor.cs | 61 +++++--- ...jectionBindingRemovingExpressionVisitor.cs | 5 +- ...ionBindingRemovingExpressionVisitorBase.cs | 2 +- ...ressionValuesExpandingExpressionVisitor.cs | 3 +- ...ingExpressionVisitor.QueryingEnumerable.cs | 15 +- ...ssionVisitor.ReadItemQueryingEnumerable.cs | 22 +-- ...osShapedQueryCompilingExpressionVisitor.cs | 13 +- .../CosmosSqlTranslatingExpressionVisitor.cs | 137 ++++++++++------- .../Internal/EntityProjectionExpression.cs | 36 +++-- .../Query/Internal/EqualsTranslator.cs | 18 ++- .../Query/Internal/IMemberTranslator.cs | 5 +- .../Internal/IMemberTranslatorProvider.cs | 5 +- .../Query/Internal/IMethodCallTranslator.cs | 4 +- .../Query/Internal/ISqlExpressionFactory.cs | 36 +++-- .../Query/Internal/InExpression.cs | 23 +-- .../Query/Internal/KeyAccessExpression.cs | 24 +-- .../Query/Internal/ObjectAccessExpression.cs | 20 ++- .../ObjectArrayProjectionExpression.cs | 27 ++-- .../Query/Internal/OrderingExpression.cs | 17 ++- .../Query/Internal/ProjectionExpression.cs | 17 ++- .../Query/Internal/QuerySqlGenerator.cs | 3 +- .../Internal/QuerySqlGeneratorFactory.cs | 3 +- .../Query/Internal/ReadItemExpression.cs | 7 +- .../Query/Internal/RootReferenceExpression.cs | 23 +-- .../Query/Internal/SelectExpression.cs | 24 +-- .../Query/Internal/SqlBinaryExpression.cs | 24 +-- .../Internal/SqlConditionalExpression.cs | 12 +- .../Query/Internal/SqlConstantExpression.cs | 18 ++- .../Query/Internal/SqlExpression.cs | 18 ++- .../Query/Internal/SqlExpressionFactory.cs | 46 ++++-- .../Query/Internal/SqlFunctionExpression.cs | 10 +- .../Query/Internal/SqlParameterExpression.cs | 6 +- .../Query/Internal/SqlUnaryExpression.cs | 23 +-- .../Query/Internal/StringMethodTranslator.cs | 16 +- .../Storage/Internal/CosmosClientWrapper.cs | 25 +-- .../Storage/Internal/CosmosConcurrencyMode.cs | 6 +- .../Storage/Internal/CosmosDatabaseCreator.cs | 3 +- .../Storage/Internal/CosmosDatabaseWrapper.cs | 16 +- .../Internal/CosmosExecutionStrategy.cs | 4 +- .../CosmosExecutionStrategyFactory.cs | 5 +- .../Internal/CosmosTransactionManager.cs | 18 ++- .../Internal/CosmosTypeMappingSource.cs | 6 +- .../Storage/Internal/JsonCosmosSerializer.cs | 3 +- .../Internal/SingletonCosmosClientWrapper.cs | 13 +- .../Update/Internal/DocumentSource.cs | 6 +- .../Internal/IdValueGenerator.cs | 3 +- .../Diagnostics/InMemoryEventId.cs | 8 +- .../InMemoryDbContextOptionsBuilder.cs | 11 +- .../Internal/InMemoryOptionsExtension.cs | 15 +- .../Internal/InMemoryModelValidator.cs | 3 +- .../DefiningQueryRewritingConvention.cs | 3 +- .../Query/Internal/AnonymousObject.cs | 9 +- .../Internal/EntityProjectionExpression.cs | 17 ++- ...yExpressionTranslatingExpressionVisitor.cs | 142 +++++++++++------- .../InMemoryGroupByShaperExpression.cs | 1 + ...emoryProjectionBindingExpressionVisitor.cs | 15 +- ...nMemoryQueryExpression.ResultEnumerable.cs | 12 +- .../Query/Internal/InMemoryQueryExpression.cs | 37 +++-- ...yableMethodTranslatingExpressionVisitor.cs | 67 ++++++--- ...jectionBindingRemovingExpressionVisitor.cs | 10 +- ...ingExpressionVisitor.QueryingEnumerable.cs | 15 +- ...ryShapedQueryCompilingExpressionVisitor.cs | 4 +- ...moryShapedQueryExpressionVisitorFactory.cs | 3 +- .../Query/Internal/InMemoryTableExpression.cs | 6 +- ...erExpressionProcessingExpressionVisitor.cs | 3 +- .../Internal/SingleResultShaperExpression.cs | 5 +- .../Storage/Internal/IInMemoryStore.cs | 3 +- .../Storage/Internal/IInMemoryTable.cs | 3 +- .../Storage/Internal/InMemoryDatabase.cs | 3 +- .../Internal/InMemoryDatabaseCreator.cs | 6 +- .../Storage/Internal/InMemoryStore.cs | 1 - .../Storage/Internal/InMemoryTable.cs | 11 +- .../Storage/Internal/InMemoryTableFactory.cs | 4 +- .../Internal/InMemoryTransactionManager.cs | 12 +- .../Internal/InMemoryIntegerValueGenerator.cs | 3 +- ...lServerNetTopologySuiteOptionsExtension.cs | 9 +- ...erverGeometryCollectionMemberTranslator.cs | 6 +- ...erverGeometryCollectionMethodTranslator.cs | 5 +- .../SqlServerGeometryMemberTranslator.cs | 5 +- .../SqlServerGeometryMethodTranslator.cs | 5 +- .../SqlServerLineStringMemberTranslator.cs | 5 +- .../SqlServerLineStringMethodTranslator.cs | 5 +- ...qlServerMultiLineStringMemberTranslator.cs | 5 +- ...rNetTopologySuiteMemberTranslatorPlugin.cs | 3 +- .../SqlServerPointMemberTranslator.cs | 5 +- .../SqlServerPolygonMemberTranslator.cs | 5 +- .../SqlServerPolygonMethodTranslator.cs | 5 +- .../SqlServerAnnotationCodeGenerator.cs | 11 +- .../Diagnostics/SqlServerEventId.cs | 11 +- .../SqlServerDatabaseFacadeExtensions.cs | 4 +- ...ServerDbContextOptionsBuilderExtensions.cs | 6 +- .../SqlServerDbFunctionsExtensions.cs | 22 ++- .../SqlServerEntityTypeBuilderExtensions.cs | 12 +- .../SqlServerEntityTypeExtensions.cs | 4 +- .../SqlServerIndexBuilderExtensions.cs | 15 +- .../Extensions/SqlServerIndexExtensions.cs | 14 +- .../SqlServerKeyBuilderExtensions.cs | 3 +- .../SqlServerMigrationBuilderExtensions.cs | 4 +- .../SqlServerModelBuilderExtensions.cs | 40 +++-- .../Extensions/SqlServerModelExtensions.cs | 31 +++- .../SqlServerPropertyBuilderExtensions.cs | 16 +- .../Extensions/SqlServerPropertyExtensions.cs | 23 ++- .../Internal/SqlServerOptionsExtension.cs | 3 +- .../Internal/SqlServerLoggerExtensions.cs | 3 +- .../Internal/SqlServerModelValidator.cs | 27 ++-- .../SqlServerConventionSetBuilder.cs | 3 +- .../SqlServerDbFunctionConvention.cs | 8 +- .../Conventions/SqlServerIndexConvention.cs | 6 +- .../SqlServerOnDeleteConvention.cs | 5 +- .../SqlServerSharedTableConvention.cs | 5 - .../SqlServerStoreGenerationConvention.cs | 2 +- ...ServerValueGenerationStrategyConvention.cs | 6 +- .../Internal/SqlServerAnnotationProvider.cs | 15 +- .../Internal/SqlServerIndexExtensions.cs | 10 +- .../SqlServerValueGenerationStrategy.cs | 1 + .../SqlServerMigrationsSqlGenerator.cs | 16 +- ...rchConditionConvertingExpressionVisitor.cs | 34 ++--- .../SqlServerByteArrayMethodTranslator.cs | 5 +- ...SqlServerCompiledQueryCacheKeyGenerator.cs | 10 +- .../Internal/SqlServerConvertTranslator.cs | 5 +- .../SqlServerDataLengthFunctionTranslator.cs | 20 +-- .../SqlServerDateDiffFunctionsTranslator.cs | 5 +- .../SqlServerDateTimeMemberTranslator.cs | 8 +- .../SqlServerDateTimeMethodTranslator.cs | 5 +- .../SqlServerFromPartsFunctionTranslator.cs | 54 +++++-- ...ServerFullTextSearchFunctionsTranslator.cs | 5 +- .../SqlServerIsDateFunctionTranslator.cs | 5 +- .../Query/Internal/SqlServerMathTranslator.cs | 5 +- .../Internal/SqlServerNewGuidTranslator.cs | 5 +- .../SqlServerObjectToStringTranslator.cs | 19 ++- .../SqlServerQueryCompilationContext.cs | 8 +- .../Internal/SqlServerQuerySqlGenerator.cs | 1 - ...qlServerSqlTranslatingExpressionVisitor.cs | 7 +- .../SqlServerStringMemberTranslator.cs | 5 +- .../SqlServerStringMethodTranslator.cs | 38 +++-- .../SqlServerTimeSpanMemberTranslator.cs | 26 ++-- .../Internal/SqlDataReaderExtension.cs | 4 +- .../Internal/SqlServerDatabaseModelFactory.cs | 4 +- .../Storage/Internal/SqlServerConnection.cs | 12 +- .../Internal/SqlServerDatabaseCreator.cs | 10 +- .../SqlServerDateTimeOffsetTypeMapping.cs | 8 +- .../Internal/SqlServerDateTimeTypeMapping.cs | 8 +- .../Internal/SqlServerDoubleTypeMapping.cs | 8 +- .../Internal/SqlServerExecutionStrategy.cs | 3 +- .../Internal/SqlServerFloatTypeMapping.cs | 8 +- .../Internal/SqlServerSqlGenerationHelper.cs | 6 +- .../Internal/SqlServerStringTypeMapping.cs | 43 +++--- .../Storage/Internal/SqlServerTransaction.cs | 8 +- .../Internal/SqlServerTransactionFactory.cs | 6 +- .../Internal/SqlServerTypeMappingSource.cs | 11 +- .../Internal/SqlServerUdtTypeMapping.cs | 1 - .../SqlServerModificationCommandBatch.cs | 3 +- .../Internal/SqlServerUpdateSqlGenerator.cs | 8 +- .../Utilities/EnumerableExtensions.cs | 9 +- .../SqlServerSequenceHiLoValueGenerator.cs | 3 +- .../SqlServerValueGeneratorSelector.cs | 3 +- .../UnexpectedConnectionTypeEventData.cs | 6 +- .../Diagnostics/SqliteEventId.cs | 16 +- .../SqliteDatabaseFacadeExtensions.cs | 4 +- .../SqliteMigrationBuilderExtensions.cs | 4 +- .../Internal/SqliteOptionsExtension.cs | 6 +- .../Infrastructure/SpatialiteLoader.cs | 10 +- .../Internal/SqliteModelValidator.cs | 6 +- .../Internal/SqliteHistoryRepository.cs | 3 +- .../SqliteMigrationsSqlGenerator.cs | 62 ++++---- .../SqliteByteArrayMethodTranslator.cs | 6 +- .../Internal/SqliteDateTimeAddTranslator.cs | 5 +- .../SqliteDateTimeMemberTranslator.cs | 5 +- .../Query/Internal/SqliteMathTranslator.cs | 5 +- ...iteQueryTranslationPostprocessorFactory.cs | 2 - ...yableMethodTranslatingExpressionVisitor.cs | 8 +- .../SqliteSqlTranslatingExpressionVisitor.cs | 32 ++-- .../Internal/SqliteStringLengthTranslator.cs | 6 +- .../Internal/SqliteStringMethodTranslator.cs | 35 +++-- .../Internal/SqliteDatabaseModelFactory.cs | 45 +++--- .../SqliteDateTimeOffsetTypeMapping.cs | 3 +- .../Internal/SqliteDateTimeTypeMapping.cs | 3 +- .../Internal/SqliteSqlGenerationHelper.cs | 1 - .../Internal/SqliteStringTypeMapping.cs | 11 +- .../Internal/SqliteUpdateSqlGenerator.cs | 5 +- .../SqliteNetTopologySuiteOptionsExtension.cs | 9 +- ...qliteGeometryCollectionMemberTranslator.cs | 5 +- ...qliteGeometryCollectionMethodTranslator.cs | 6 +- .../SqliteGeometryMemberTranslator.cs | 18 ++- .../SqliteGeometryMethodTranslator.cs | 24 +-- .../SqliteLineStringMemberTranslator.cs | 6 +- .../SqliteLineStringMethodTranslator.cs | 6 +- .../SqliteMultiLineStringMemberTranslator.cs | 6 +- .../Internal/SqlitePointMemberTranslator.cs | 6 +- .../Internal/SqlitePolygonMemberTranslator.cs | 6 +- .../Internal/SqlitePolygonMethodTranslator.cs | 8 +- src/Shared/Check.cs | 2 +- 215 files changed, 1707 insertions(+), 984 deletions(-) diff --git a/src/EFCore.Cosmos/Diagnostics/CosmosEventId.cs b/src/EFCore.Cosmos/Diagnostics/CosmosEventId.cs index eae88cb19a1..6d95499634e 100644 --- a/src/EFCore.Cosmos/Diagnostics/CosmosEventId.cs +++ b/src/EFCore.Cosmos/Diagnostics/CosmosEventId.cs @@ -31,7 +31,9 @@ private enum Id } private static readonly string _queryPrefix = DbLoggerCategory.Query.Name + "."; - private static EventId MakeQueryId(Id id) => new EventId((int)id, _queryPrefix + id); + + private static EventId MakeQueryId(Id id) + => new EventId((int)id, _queryPrefix + id); /// /// diff --git a/src/EFCore.Cosmos/Extensions/CosmosDbContextOptionsExtensions.cs b/src/EFCore.Cosmos/Extensions/CosmosDbContextOptionsExtensions.cs index 84a1d12a676..64891348245 100644 --- a/src/EFCore.Cosmos/Extensions/CosmosDbContextOptionsExtensions.cs +++ b/src/EFCore.Cosmos/Extensions/CosmosDbContextOptionsExtensions.cs @@ -61,7 +61,7 @@ public static DbContextOptionsBuilder UseCosmos( Check.NotEmpty(databaseName, nameof(databaseName)); var extension = optionsBuilder.Options.FindExtension() - ?? new CosmosOptionsExtension(); + ?? new CosmosOptionsExtension(); extension = extension .WithAccountEndpoint(accountEndpoint) @@ -115,7 +115,7 @@ public static DbContextOptionsBuilder UseCosmos( Check.NotNull(databaseName, nameof(databaseName)); var extension = optionsBuilder.Options.FindExtension() - ?? new CosmosOptionsExtension(); + ?? new CosmosOptionsExtension(); extension = extension .WithConnectionString(connectionString) diff --git a/src/EFCore.Cosmos/Extensions/CosmosEntityTypeBuilderExtensions.cs b/src/EFCore.Cosmos/Extensions/CosmosEntityTypeBuilderExtensions.cs index 6cfd2d21506..9f3c918835f 100644 --- a/src/EFCore.Cosmos/Extensions/CosmosEntityTypeBuilderExtensions.cs +++ b/src/EFCore.Cosmos/Extensions/CosmosEntityTypeBuilderExtensions.cs @@ -83,7 +83,9 @@ public static IConventionEntityTypeBuilder ToContainer( /// Indicates whether the configuration was specified using a data annotation. /// if the configuration can be applied. public static bool CanSetContainer( - [NotNull] this IConventionEntityTypeBuilder entityTypeBuilder, [CanBeNull] string name, bool fromDataAnnotation = false) + [NotNull] this IConventionEntityTypeBuilder entityTypeBuilder, + [CanBeNull] string name, + bool fromDataAnnotation = false) { Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); Check.NullButNotEmpty(name, nameof(name)); @@ -157,7 +159,9 @@ public static IConventionEntityTypeBuilder ToJsonProperty( /// Indicates whether the configuration was specified using a data annotation. /// if the configuration can be applied. public static bool CanSetJsonProperty( - [NotNull] this IConventionEntityTypeBuilder entityTypeBuilder, [CanBeNull] string name, bool fromDataAnnotation = false) + [NotNull] this IConventionEntityTypeBuilder entityTypeBuilder, + [CanBeNull] string name, + bool fromDataAnnotation = false) { Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); Check.NullButNotEmpty(name, nameof(name)); @@ -248,7 +252,9 @@ public static IConventionEntityTypeBuilder HasPartitionKey( /// Indicates whether the configuration was specified using a data annotation. /// if the configuration can be applied. public static bool CanSetPartitionKey( - [NotNull] this IConventionEntityTypeBuilder entityTypeBuilder, [CanBeNull] string name, bool fromDataAnnotation = false) + [NotNull] this IConventionEntityTypeBuilder entityTypeBuilder, + [CanBeNull] string name, + bool fromDataAnnotation = false) { Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); Check.NullButNotEmpty(name, nameof(name)); diff --git a/src/EFCore.Cosmos/Extensions/CosmosEntityTypeExtensions.cs b/src/EFCore.Cosmos/Extensions/CosmosEntityTypeExtensions.cs index 48c3c9d1664..06df02876a3 100644 --- a/src/EFCore.Cosmos/Extensions/CosmosEntityTypeExtensions.cs +++ b/src/EFCore.Cosmos/Extensions/CosmosEntityTypeExtensions.cs @@ -19,17 +19,17 @@ public static class CosmosEntityTypeExtensions /// /// The entity type to get the container name for. /// The name of the container to which the entity type is mapped. - public static string GetContainer([NotNull] this IEntityType entityType) => - entityType.BaseType != null + public static string GetContainer([NotNull] this IEntityType entityType) + => entityType.BaseType != null ? entityType.GetRootType().GetContainer() : (string)entityType[CosmosAnnotationNames.ContainerName] - ?? GetDefaultContainer(entityType); + ?? GetDefaultContainer(entityType); private static string GetDefaultContainer(IEntityType entityType) => entityType.IsOwned() ? null : entityType.Model.GetDefaultContainer() - ?? entityType.ShortName(); + ?? entityType.ShortName(); /// /// Sets the name of the container to which the entity type is mapped. @@ -48,7 +48,9 @@ public static void SetContainer([NotNull] this IMutableEntityType entityType, [C /// The name to set. /// Indicates whether the configuration was specified using a data annotation. public static void SetContainer( - [NotNull] this IConventionEntityType entityType, [CanBeNull] string name, bool fromDataAnnotation = false) + [NotNull] this IConventionEntityType entityType, + [CanBeNull] string name, + bool fromDataAnnotation = false) => entityType.SetOrRemoveAnnotation( CosmosAnnotationNames.ContainerName, Check.NullButNotEmpty(name, nameof(name)), @@ -68,9 +70,9 @@ public static void SetContainer( /// /// The entity type to get the containing property name for. /// The name of the parent property to which the entity type is mapped. - public static string GetContainingPropertyName([NotNull] this IEntityType entityType) => - entityType[CosmosAnnotationNames.PropertyName] as string - ?? GetDefaultContainingPropertyName(entityType); + public static string GetContainingPropertyName([NotNull] this IEntityType entityType) + => entityType[CosmosAnnotationNames.PropertyName] as string + ?? GetDefaultContainingPropertyName(entityType); private static string GetDefaultContainingPropertyName(IEntityType entityType) => entityType.FindOwnership()?.PrincipalToDependent.Name; @@ -92,7 +94,9 @@ public static void SetContainingPropertyName([NotNull] this IMutableEntityType e /// The name to set. /// Indicates whether the configuration was specified using a data annotation. public static void SetContainingPropertyName( - [NotNull] this IConventionEntityType entityType, [CanBeNull] string name, bool fromDataAnnotation = false) + [NotNull] this IConventionEntityType entityType, + [CanBeNull] string name, + bool fromDataAnnotation = false) => entityType.SetOrRemoveAnnotation( CosmosAnnotationNames.PropertyName, Check.NullButNotEmpty(name, nameof(name)), @@ -132,7 +136,9 @@ public static void SetPartitionKeyPropertyName([NotNull] this IMutableEntityType /// The name to set. /// Indicates whether the configuration was specified using a data annotation. public static void SetPartitionKeyPropertyName( - [NotNull] this IConventionEntityType entityType, [CanBeNull] string name, bool fromDataAnnotation = false) + [NotNull] this IConventionEntityType entityType, + [CanBeNull] string name, + bool fromDataAnnotation = false) => entityType.SetOrRemoveAnnotation( CosmosAnnotationNames.PartitionKeyName, Check.NullButNotEmpty(name, nameof(name)), @@ -172,7 +178,9 @@ public static void SetETagPropertyName([NotNull] this IMutableEntityType entityT /// The name to set. /// Indicates whether the configuration was specified using a data annotation. public static void SetETagPropertyName( - [NotNull] this IConventionEntityType entityType, [CanBeNull] string name, bool fromDataAnnotation = false) + [NotNull] this IConventionEntityType entityType, + [CanBeNull] string name, + bool fromDataAnnotation = false) => entityType.SetOrRemoveAnnotation( CosmosAnnotationNames.ETagName, Check.NullButNotEmpty(name, nameof(name)), @@ -188,10 +196,10 @@ public static void SetETagPropertyName( ?.GetConfigurationSource(); /// - /// Gets the on this entity that is mapped to cosmos etag, if it exists. + /// Gets the on this entity that is mapped to cosmos etag, if it exists. /// /// The entity type to get the etag property for. - /// The mapped to etag, or null if no property is mapped to etag. + /// The mapped to etag, or null if no property is mapped to etag. public static IProperty GetETagProperty([NotNull] this IEntityType entityType) { Check.NotNull(entityType, nameof(entityType)); diff --git a/src/EFCore.Cosmos/Extensions/CosmosModelExtensions.cs b/src/EFCore.Cosmos/Extensions/CosmosModelExtensions.cs index 92172a5f4c6..c88a8e7ab89 100644 --- a/src/EFCore.Cosmos/Extensions/CosmosModelExtensions.cs +++ b/src/EFCore.Cosmos/Extensions/CosmosModelExtensions.cs @@ -40,7 +40,9 @@ public static void SetDefaultContainer([NotNull] this IMutableModel model, [CanB /// Indicates whether the configuration was specified using a data annotation. /// The configured value. public static string SetDefaultContainer( - [NotNull] this IConventionModel model, [CanBeNull] string name, bool fromDataAnnotation = false) + [NotNull] this IConventionModel model, + [CanBeNull] string name, + bool fromDataAnnotation = false) { model.SetOrRemoveAnnotation( CosmosAnnotationNames.ContainerName, diff --git a/src/EFCore.Cosmos/Extensions/CosmosPropertyExtensions.cs b/src/EFCore.Cosmos/Extensions/CosmosPropertyExtensions.cs index d055fefd222..8db108e8e7b 100644 --- a/src/EFCore.Cosmos/Extensions/CosmosPropertyExtensions.cs +++ b/src/EFCore.Cosmos/Extensions/CosmosPropertyExtensions.cs @@ -19,9 +19,9 @@ public static class CosmosPropertyExtensions /// /// The property. /// Returns the property name that the property is mapped to when targeting Cosmos. - public static string GetJsonPropertyName([NotNull] this IProperty property) => - (string)property[CosmosAnnotationNames.PropertyName] - ?? GetDefaultJsonPropertyName(property); + public static string GetJsonPropertyName([NotNull] this IProperty property) + => (string)property[CosmosAnnotationNames.PropertyName] + ?? GetDefaultJsonPropertyName(property); private static string GetDefaultJsonPropertyName(IProperty property) { @@ -62,7 +62,9 @@ public static void SetJsonPropertyName([NotNull] this IMutableProperty property, /// Indicates whether the configuration was specified using a data annotation. /// The configured value. public static string SetJsonPropertyName( - [NotNull] this IConventionProperty property, [CanBeNull] string name, bool fromDataAnnotation = false) + [NotNull] this IConventionProperty property, + [CanBeNull] string name, + bool fromDataAnnotation = false) { property.SetOrRemoveAnnotation( CosmosAnnotationNames.PropertyName, diff --git a/src/EFCore.Cosmos/Extensions/CosmosQueryableExtensions.cs b/src/EFCore.Cosmos/Extensions/CosmosQueryableExtensions.cs index b8d70437e63..6390979b93a 100644 --- a/src/EFCore.Cosmos/Extensions/CosmosQueryableExtensions.cs +++ b/src/EFCore.Cosmos/Extensions/CosmosQueryableExtensions.cs @@ -24,7 +24,7 @@ internal static readonly MethodInfo WithPartitionKeyMethodInfo /// /// Specify the partition key for partition used for the query. Required when using - /// a resource token that provides permission based on a partition key for authentication, + /// a resource token that provides permission based on a partition key for authentication, /// /// The type of entity being queried. /// The source query. diff --git a/src/EFCore.Cosmos/Infrastructure/CosmosDbContextOptionsBuilder.cs b/src/EFCore.Cosmos/Infrastructure/CosmosDbContextOptionsBuilder.cs index d84e03d2f59..e1f69174a94 100644 --- a/src/EFCore.Cosmos/Infrastructure/CosmosDbContextOptionsBuilder.cs +++ b/src/EFCore.Cosmos/Infrastructure/CosmosDbContextOptionsBuilder.cs @@ -55,7 +55,7 @@ public virtual CosmosDbContextOptionsBuilder Region([NotNull] string region) /// /// Limits the operations to the provided endpoint. /// - /// to limit the operations to the provided endpoint. + /// to limit the operations to the provided endpoint. public virtual CosmosDbContextOptionsBuilder LimitToEndpoint(bool enable = true) => WithOption(e => e.WithLimitToEndpoint(Check.NotNull(enable, nameof(enable)))); @@ -141,22 +141,25 @@ protected virtual CosmosDbContextOptionsBuilder WithOption([NotNull] Func /// A string that represents the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override string ToString() => base.ToString(); + public override string ToString() + => base.ToString(); /// /// Determines whether the specified object is equal to the current object. /// /// The object to compare with the current object. - /// if the specified object is equal to the current object; otherwise, . + /// if the specified object is equal to the current object; otherwise, . [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => base.Equals(obj); + public override bool Equals(object obj) + => base.Equals(obj); /// /// Serves as the default hash function. /// /// A hash code for the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); #endregion } diff --git a/src/EFCore.Cosmos/Infrastructure/Internal/CosmosDbOptionExtension.cs b/src/EFCore.Cosmos/Infrastructure/Internal/CosmosDbOptionExtension.cs index e21ab8c5d2b..9f388f8782d 100644 --- a/src/EFCore.Cosmos/Infrastructure/Internal/CosmosDbOptionExtension.cs +++ b/src/EFCore.Cosmos/Infrastructure/Internal/CosmosDbOptionExtension.cs @@ -91,7 +91,8 @@ public virtual DbContextOptionsExtensionInfo Info /// 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 virtual string AccountEndpoint => _accountEndpoint; + public virtual string AccountEndpoint + => _accountEndpoint; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -119,7 +120,8 @@ public virtual CosmosOptionsExtension WithAccountEndpoint([NotNull] string accou /// 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 virtual string AccountKey => _accountKey; + public virtual string AccountKey + => _accountKey; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -147,7 +149,8 @@ public virtual CosmosOptionsExtension WithAccountKey([NotNull] string accountKey /// 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 virtual string ConnectionString => _connectionString; + public virtual string ConnectionString + => _connectionString; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -175,7 +178,8 @@ public virtual CosmosOptionsExtension WithConnectionString([NotNull] string conn /// 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 virtual string DatabaseName => _databaseName; + public virtual string DatabaseName + => _databaseName; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -198,7 +202,8 @@ public virtual CosmosOptionsExtension WithDatabaseName([NotNull] string database /// 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 virtual string Region => _region; + public virtual string Region + => _region; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -221,7 +226,8 @@ public virtual CosmosOptionsExtension WithRegion([NotNull] string region) /// 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 virtual bool? LimitToEndpoint => _limitToEndpoint; + public virtual bool? LimitToEndpoint + => _limitToEndpoint; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -244,7 +250,8 @@ public virtual CosmosOptionsExtension WithLimitToEndpoint(bool enable) /// 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 virtual ConnectionMode? ConnectionMode => _connectionMode; + public virtual ConnectionMode? ConnectionMode + => _connectionMode; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -272,7 +279,8 @@ public virtual CosmosOptionsExtension WithConnectionMode(ConnectionMode connecti /// 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 virtual IWebProxy WebProxy => _webProxy; + public virtual IWebProxy WebProxy + => _webProxy; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -295,7 +303,8 @@ public virtual CosmosOptionsExtension WithWebProxy([NotNull] IWebProxy proxy) /// 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 virtual TimeSpan? RequestTimeout => _requestTimeout; + public virtual TimeSpan? RequestTimeout + => _requestTimeout; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -318,7 +327,8 @@ public virtual CosmosOptionsExtension WithRequestTimeout(TimeSpan timeout) /// 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 virtual TimeSpan? OpenTcpConnectionTimeout => _openTcpConnectionTimeout; + public virtual TimeSpan? OpenTcpConnectionTimeout + => _openTcpConnectionTimeout; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -341,7 +351,8 @@ public virtual CosmosOptionsExtension WithOpenTcpConnectionTimeout(TimeSpan time /// 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 virtual TimeSpan? IdleTcpConnectionTimeout => _idleTcpConnectionTimeout; + public virtual TimeSpan? IdleTcpConnectionTimeout + => _idleTcpConnectionTimeout; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -364,7 +375,8 @@ public virtual CosmosOptionsExtension WithIdleTcpConnectionTimeout(TimeSpan time /// 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 virtual int? GatewayModeMaxConnectionLimit => _gatewayModeMaxConnectionLimit; + public virtual int? GatewayModeMaxConnectionLimit + => _gatewayModeMaxConnectionLimit; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -387,7 +399,8 @@ public virtual CosmosOptionsExtension WithGatewayModeMaxConnectionLimit(int conn /// 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 virtual int? MaxTcpConnectionsPerEndpoint => _maxTcpConnectionsPerEndpoint; + public virtual int? MaxTcpConnectionsPerEndpoint + => _maxTcpConnectionsPerEndpoint; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -410,7 +423,8 @@ public virtual CosmosOptionsExtension WithMaxTcpConnectionsPerEndpoint(int conne /// 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 virtual int? MaxRequestsPerTcpConnection => _maxRequestsPerTcpConnection; + public virtual int? MaxRequestsPerTcpConnection + => _maxRequestsPerTcpConnection; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -431,7 +445,8 @@ public virtual CosmosOptionsExtension WithMaxRequestsPerTcpConnection(int reques /// A factory for creating the default , or if none has been /// configured. /// - public virtual Func ExecutionStrategyFactory => _executionStrategyFactory; + public virtual Func ExecutionStrategyFactory + => _executionStrategyFactory; /// /// Creates a new instance with all options the same as for this instance, but with the given option changed. @@ -455,7 +470,8 @@ public virtual CosmosOptionsExtension WithExecutionStrategyFactory( /// 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. /// - protected virtual CosmosOptionsExtension Clone() => new CosmosOptionsExtension(this); + protected virtual CosmosOptionsExtension Clone() + => new CosmosOptionsExtension(this); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -489,7 +505,8 @@ public ExtensionInfo(IDbContextOptionsExtension extension) private new CosmosOptionsExtension Extension => (CosmosOptionsExtension)base.Extension; - public override bool IsDatabaseProvider => true; + public override bool IsDatabaseProvider + => true; public override long GetServiceProviderHashCode() { @@ -528,12 +545,13 @@ public override void PopulateDebugInfo(IDictionary debugInfo) if (!string.IsNullOrEmpty(Extension._connectionString)) { - debugInfo["Cosmos:" + nameof(ConnectionString)] = Extension._connectionString.GetHashCode().ToString(CultureInfo.InvariantCulture); + debugInfo["Cosmos:" + nameof(ConnectionString)] = + Extension._connectionString.GetHashCode().ToString(CultureInfo.InvariantCulture); } else { debugInfo["Cosmos:" + nameof(AccountEndpoint)] = - Extension._accountEndpoint.GetHashCode().ToString(CultureInfo.InvariantCulture); + Extension._accountEndpoint.GetHashCode().ToString(CultureInfo.InvariantCulture); debugInfo["Cosmos:" + nameof(AccountKey)] = Extension._accountKey.GetHashCode().ToString(CultureInfo.InvariantCulture); } diff --git a/src/EFCore.Cosmos/Infrastructure/Internal/CosmosSingletonOptions.cs b/src/EFCore.Cosmos/Infrastructure/Internal/CosmosSingletonOptions.cs index 39282b5b194..375e3b07b81 100644 --- a/src/EFCore.Cosmos/Infrastructure/Internal/CosmosSingletonOptions.cs +++ b/src/EFCore.Cosmos/Infrastructure/Internal/CosmosSingletonOptions.cs @@ -4,7 +4,6 @@ using System; using System.Net; using Azure.Cosmos; -using Microsoft.Azure.Cosmos; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.Extensions.DependencyInjection; diff --git a/src/EFCore.Cosmos/Infrastructure/Internal/ICosmosSingletonOptions.cs b/src/EFCore.Cosmos/Infrastructure/Internal/ICosmosSingletonOptions.cs index 547c52aea77..ff1b1ad4a06 100644 --- a/src/EFCore.Cosmos/Infrastructure/Internal/ICosmosSingletonOptions.cs +++ b/src/EFCore.Cosmos/Infrastructure/Internal/ICosmosSingletonOptions.cs @@ -95,7 +95,7 @@ public interface ICosmosSingletonOptions : ISingletonOptions /// 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. /// - TimeSpan? OpenTcpConnectionTimeout { get; } + TimeSpan? OpenTcpConnectionTimeout { get; } /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Cosmos/Internal/CosmosModelValidator.cs b/src/EFCore.Cosmos/Internal/CosmosModelValidator.cs index b19f2a5ddbe..03fd6d0fc38 100644 --- a/src/EFCore.Cosmos/Internal/CosmosModelValidator.cs +++ b/src/EFCore.Cosmos/Internal/CosmosModelValidator.cs @@ -220,7 +220,8 @@ protected virtual void ValidateKeys( continue; } - var idProperty = entityType.GetProperties().FirstOrDefault(p => p.GetJsonPropertyName() == StoreKeyConvention.IdPropertyJsonName); + var idProperty = entityType.GetProperties() + .FirstOrDefault(p => p.GetJsonPropertyName() == StoreKeyConvention.IdPropertyJsonName); if (idProperty == null) { throw new InvalidOperationException(CosmosStrings.NoIdProperty(entityType.DisplayName())); @@ -261,8 +262,9 @@ protected virtual void ValidateKeys( if (!partitionKey.GetContainingKeys().Any(k => k.Properties.Contains(idProperty))) { - throw new InvalidOperationException(CosmosStrings.NoPartitionKeyKey( - entityType.DisplayName(), partitionKeyPropertyName, idProperty.Name)); + throw new InvalidOperationException( + CosmosStrings.NoPartitionKeyKey( + entityType.DisplayName(), partitionKeyPropertyName, idProperty.Name)); } } } @@ -294,10 +296,8 @@ protected virtual void ValidateDatabaseProperties( throw new InvalidOperationException( CosmosStrings.JsonPropertyCollision(property.Name, otherProperty.Name, entityType.DisplayName(), jsonName)); } - else - { - properties[jsonName] = property; - } + + properties[jsonName] = property; } foreach (var navigation in entityType.GetNavigations()) @@ -313,10 +313,8 @@ protected virtual void ValidateDatabaseProperties( throw new InvalidOperationException( CosmosStrings.JsonPropertyCollision(navigation.Name, otherProperty.Name, entityType.DisplayName(), jsonName)); } - else - { - properties[jsonName] = navigation; - } + + properties[jsonName] = navigation; } } } diff --git a/src/EFCore.Cosmos/Metadata/Conventions/StoreKeyConvention.cs b/src/EFCore.Cosmos/Metadata/Conventions/StoreKeyConvention.cs index 1f7204646d6..7cd6dbcedbd 100644 --- a/src/EFCore.Cosmos/Metadata/Conventions/StoreKeyConvention.cs +++ b/src/EFCore.Cosmos/Metadata/Conventions/StoreKeyConvention.cs @@ -9,7 +9,6 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure; -using Microsoft.EntityFrameworkCore.Utilities; using Newtonsoft.Json.Linq; // ReSharper disable once CheckNamespace @@ -117,6 +116,7 @@ private static void ProcessIdProperty(IConventionEntityTypeBuilder entityTypeBui { newKey = entityTypeBuilder.HasKey(new[] { idProperty, partitionKeyProperty })?.Metadata; } + entityTypeBuilder.HasNoKey(new[] { idProperty }); } } diff --git a/src/EFCore.Cosmos/Metadata/Internal/CosmosEntityTypeExtensions.cs b/src/EFCore.Cosmos/Metadata/Internal/CosmosEntityTypeExtensions.cs index 0648779f8c1..348c0f3bddf 100644 --- a/src/EFCore.Cosmos/Metadata/Internal/CosmosEntityTypeExtensions.cs +++ b/src/EFCore.Cosmos/Metadata/Internal/CosmosEntityTypeExtensions.cs @@ -22,7 +22,7 @@ public static class CosmosEntityTypeExtensions /// public static bool IsDocumentRoot([NotNull] this IEntityType entityType) => entityType.BaseType?.IsDocumentRoot() - ?? (!entityType.IsOwned() - || entityType[CosmosAnnotationNames.ContainerName] != null); + ?? (!entityType.IsOwned() + || entityType[CosmosAnnotationNames.ContainerName] != null); } } diff --git a/src/EFCore.Cosmos/Metadata/Internal/CosmosNavigationExtensions.cs b/src/EFCore.Cosmos/Metadata/Internal/CosmosNavigationExtensions.cs index 90e85837f1f..6448b9a1c0d 100644 --- a/src/EFCore.Cosmos/Metadata/Internal/CosmosNavigationExtensions.cs +++ b/src/EFCore.Cosmos/Metadata/Internal/CosmosNavigationExtensions.cs @@ -22,6 +22,6 @@ public static class CosmosNavigationExtensions /// public static bool IsEmbedded([NotNull] this INavigation navigation) => !navigation.IsOnDependent - && !navigation.ForeignKey.DeclaringEntityType.IsDocumentRoot(); + && !navigation.ForeignKey.DeclaringEntityType.IsDocumentRoot(); } } diff --git a/src/EFCore.Cosmos/Metadata/Internal/CosmosPropertyExtensions.cs b/src/EFCore.Cosmos/Metadata/Internal/CosmosPropertyExtensions.cs index d7f2cf82af2..3462afb7b6c 100644 --- a/src/EFCore.Cosmos/Metadata/Internal/CosmosPropertyExtensions.cs +++ b/src/EFCore.Cosmos/Metadata/Internal/CosmosPropertyExtensions.cs @@ -23,7 +23,8 @@ public static class CosmosPropertyExtensions /// public static bool IsOrdinalKeyProperty([NotNull] this IProperty property) { - Check.DebugAssert(property.DeclaringEntityType.IsOwned(), $"Expected {property.DeclaringEntityType.DisplayName()} to be owned."); + Check.DebugAssert( + property.DeclaringEntityType.IsOwned(), $"Expected {property.DeclaringEntityType.DisplayName()} to be owned."); Check.DebugAssert(property.GetJsonPropertyName().Length == 0, $"Expected {property.Name} to be non-persisted."); return property.IsPrimaryKey() diff --git a/src/EFCore.Cosmos/Query/Internal/ContainsTranslator.cs b/src/EFCore.Cosmos/Query/Internal/ContainsTranslator.cs index ee5eff7e9d7..922916b4fc9 100644 --- a/src/EFCore.Cosmos/Query/Internal/ContainsTranslator.cs +++ b/src/EFCore.Cosmos/Query/Internal/ContainsTranslator.cs @@ -35,7 +35,10 @@ public ContainsTranslator([NotNull] ISqlExpressionFactory sqlExpressionFactory) /// 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 virtual SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList arguments, + public virtual SqlExpression Translate( + SqlExpression instance, + MethodInfo method, + IReadOnlyList arguments, IDiagnosticsLogger logger) { if (method.IsGenericMethod diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosMemberTranslatorProvider.cs b/src/EFCore.Cosmos/Query/Internal/CosmosMemberTranslatorProvider.cs index 73aba51a107..2712a7470e3 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosMemberTranslatorProvider.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosMemberTranslatorProvider.cs @@ -48,7 +48,10 @@ public CosmosMemberTranslatorProvider( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MemberInfo member, Type returnType, IDiagnosticsLogger logger) + SqlExpression instance, + MemberInfo member, + Type returnType, + IDiagnosticsLogger logger) { Check.NotNull(instance, nameof(instance)); Check.NotNull(member, nameof(member)); diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosMethodCallTranslatorProvider.cs b/src/EFCore.Cosmos/Query/Internal/CosmosMethodCallTranslatorProvider.cs index 2b386a5e0d1..94f1b066f23 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosMethodCallTranslatorProvider.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosMethodCallTranslatorProvider.cs @@ -54,7 +54,10 @@ public CosmosMethodCallTranslatorProvider( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - IModel model, SqlExpression instance, MethodInfo method, IReadOnlyList arguments, + IModel model, + SqlExpression instance, + MethodInfo method, + IReadOnlyList arguments, IDiagnosticsLogger logger) { Check.NotNull(model, nameof(model)); diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosProjectionBindingExpressionVisitor.cs b/src/EFCore.Cosmos/Query/Internal/CosmosProjectionBindingExpressionVisitor.cs index 2bfbcce59d7..2c9854a2182 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosProjectionBindingExpressionVisitor.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosProjectionBindingExpressionVisitor.cs @@ -53,7 +53,8 @@ private readonly Stack _includedNavigations /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public CosmosProjectionBindingExpressionVisitor( - [NotNull] IModel model, [NotNull] CosmosSqlTranslatingExpressionVisitor sqlTranslator) + [NotNull] IModel model, + [NotNull] CosmosSqlTranslatingExpressionVisitor sqlTranslator) { _model = model; _sqlTranslator = sqlTranslator; @@ -133,7 +134,8 @@ public override Expression Visit(Expression expression) return parameterExpression; } - if (parameterExpression.Name?.StartsWith(QueryCompilationContext.QueryParameterPrefix, StringComparison.Ordinal) == true) + if (parameterExpression.Name?.StartsWith(QueryCompilationContext.QueryParameterPrefix, StringComparison.Ordinal) + == true) { return Expression.Call( _getParameterValueMethodInfo.MakeGenericMethod(parameterExpression.Type), @@ -241,8 +243,8 @@ protected override Expression VisitExtension(Expression extensionExpression) case MaterializeCollectionNavigationExpression materializeCollectionNavigationExpression: return materializeCollectionNavigationExpression.Navigation is INavigation embeddableNavigation && embeddableNavigation.IsEmbedded() - ? base.Visit(materializeCollectionNavigationExpression.Subquery) - : base.VisitExtension(materializeCollectionNavigationExpression); + ? base.Visit(materializeCollectionNavigationExpression.Subquery) + : base.VisitExtension(materializeCollectionNavigationExpression); case IncludeExpression includeExpression: if (!_clientEval) @@ -708,10 +710,10 @@ protected override Expression VisitUnary(UnaryExpression unaryExpression) var operand = Visit(unaryExpression.Operand); return (unaryExpression.NodeType == ExpressionType.Convert - || unaryExpression.NodeType == ExpressionType.ConvertChecked) + || unaryExpression.NodeType == ExpressionType.ConvertChecked) && unaryExpression.Type == operand.Type - ? operand - : unaryExpression.Update(MatchTypes(operand, unaryExpression.Operand.Type)); + ? operand + : unaryExpression.Update(MatchTypes(operand, unaryExpression.Operand.Type)); } // TODO: Debugging diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosQueryCompilationContext.cs b/src/EFCore.Cosmos/Query/Internal/CosmosQueryCompilationContext.cs index 3f2bc134e5b..d29dd4e46a3 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosQueryCompilationContext.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosQueryCompilationContext.cs @@ -21,7 +21,8 @@ public class CosmosQueryCompilationContext : QueryCompilationContext /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public CosmosQueryCompilationContext( - [NotNull] QueryCompilationContextDependencies dependencies, bool async) + [NotNull] QueryCompilationContextDependencies dependencies, + bool async) : base(dependencies, async) { } diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosQueryMetadataExtractingExpressionVisitor.cs b/src/EFCore.Cosmos/Query/Internal/CosmosQueryMetadataExtractingExpressionVisitor.cs index 0318c4ef57b..27591238144 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosQueryMetadataExtractingExpressionVisitor.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosQueryMetadataExtractingExpressionVisitor.cs @@ -42,7 +42,8 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp { var innerQueryable = Visit(methodCallExpression.Arguments[0]); - _cosmosQueryCompilationContext.PartitionKeyFromExtension = (string)((ConstantExpression)methodCallExpression.Arguments[1]).Value; + _cosmosQueryCompilationContext.PartitionKeyFromExtension = + (string)((ConstantExpression)methodCallExpression.Arguments[1]).Value; return innerQueryable; } diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosQueryTranslationPreprocessorFactory.cs b/src/EFCore.Cosmos/Query/Internal/CosmosQueryTranslationPreprocessorFactory.cs index b147f824343..b38ccbf7047 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosQueryTranslationPreprocessorFactory.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosQueryTranslationPreprocessorFactory.cs @@ -45,6 +45,6 @@ public CosmosQueryTranslationPreprocessorFactory( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual QueryTranslationPreprocessor Create(QueryCompilationContext queryCompilationContext) - => new CosmosQueryTranslationPreprocessor(_dependencies, (CosmosQueryCompilationContext)queryCompilationContext); + => new CosmosQueryTranslationPreprocessor(_dependencies, (CosmosQueryCompilationContext)queryCompilationContext); } } diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosQueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore.Cosmos/Query/Internal/CosmosQueryableMethodTranslatingExpressionVisitor.cs index 91cdbf66b9d..206f25ce8f6 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosQueryableMethodTranslatingExpressionVisitor.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosQueryableMethodTranslatingExpressionVisitor.cs @@ -56,7 +56,8 @@ public CosmosQueryableMethodTranslatingExpressionVisitor( _sqlExpressionFactory, _memberTranslatorProvider, _methodCallTranslatorProvider); - _projectionBindingExpressionVisitor = new CosmosProjectionBindingExpressionVisitor(_queryCompilationContext.Model, _sqlTranslator); + _projectionBindingExpressionVisitor = + new CosmosProjectionBindingExpressionVisitor(_queryCompilationContext.Model, _sqlTranslator); } /// @@ -76,7 +77,8 @@ protected CosmosQueryableMethodTranslatingExpressionVisitor( _sqlExpressionFactory, _memberTranslatorProvider, _methodCallTranslatorProvider); - _projectionBindingExpressionVisitor = new CosmosProjectionBindingExpressionVisitor(_queryCompilationContext.Model, _sqlTranslator); + _projectionBindingExpressionVisitor = + new CosmosProjectionBindingExpressionVisitor(_queryCompilationContext.Model, _sqlTranslator); } /// @@ -118,8 +120,9 @@ public override Expression Visit(Expression expression) && (idProperty.GetValueGeneratorFactory() != null || entityTypePrimaryKeyProperties.Contains(idProperty))) { - var propertyParameterList = queryProperties.Zip(parameterNames, - (property, parameter) => (property, parameter)) + var propertyParameterList = queryProperties.Zip( + parameterNames, + (property, parameter) => (property, parameter)) .ToDictionary(tuple => tuple.property, tuple => tuple.parameter); var readItemExpression = new ReadItemExpression(entityType, propertyParameterList); @@ -135,8 +138,11 @@ public override Expression Visit(Expression expression) return base.Visit(expression); - static bool ExtractPartitionKeyFromPredicate(IEntityType entityType, Expression joinCondition, - ICollection properties, ICollection parameterNames) + static bool ExtractPartitionKeyFromPredicate( + IEntityType entityType, + Expression joinCondition, + ICollection properties, + ICollection parameterNames) { if (joinCondition is BinaryExpression joinBinaryExpression) { @@ -156,6 +162,7 @@ static bool ExtractPartitionKeyFromPredicate(IEntityType entityType, Expression { return false; } + properties.Add(property); parameterNames.Add(equalParameterExpresion.Name); return true; @@ -427,7 +434,9 @@ protected override ShapedQueryExpression TranslateDistinct(ShapedQueryExpression /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ShapedQueryExpression TranslateElementAtOrDefault( - ShapedQueryExpression source, Expression index, bool returnDefault) + ShapedQueryExpression source, + Expression index, + bool returnDefault) { Check.NotNull(source, nameof(source)); Check.NotNull(index, nameof(index)); @@ -456,7 +465,10 @@ protected override ShapedQueryExpression TranslateExcept(ShapedQueryExpression s /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ShapedQueryExpression TranslateFirstOrDefault( - ShapedQueryExpression source, LambdaExpression predicate, Type returnType, bool returnDefault) + ShapedQueryExpression source, + LambdaExpression predicate, + Type returnType, + bool returnDefault) { Check.NotNull(source, nameof(source)); Check.NotNull(returnType, nameof(returnType)); @@ -565,7 +577,10 @@ protected override ShapedQueryExpression TranslateJoin( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ShapedQueryExpression TranslateLastOrDefault( - ShapedQueryExpression source, LambdaExpression predicate, Type returnType, bool returnDefault) + ShapedQueryExpression source, + LambdaExpression predicate, + Type returnType, + bool returnDefault) { Check.NotNull(source, nameof(source)); Check.NotNull(returnType, nameof(returnType)); @@ -775,7 +790,9 @@ protected override ShapedQueryExpression TranslateOfType(ShapedQueryExpression s /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ShapedQueryExpression TranslateOrderBy( - ShapedQueryExpression source, LambdaExpression keySelector, bool ascending) + ShapedQueryExpression source, + LambdaExpression keySelector, + bool ascending) { Check.NotNull(source, nameof(source)); Check.NotNull(keySelector, nameof(keySelector)); @@ -847,7 +864,9 @@ protected override ShapedQueryExpression TranslateSelect(ShapedQueryExpression s /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ShapedQueryExpression TranslateSelectMany( - ShapedQueryExpression source, LambdaExpression collectionSelector, LambdaExpression resultSelector) + ShapedQueryExpression source, + LambdaExpression collectionSelector, + LambdaExpression resultSelector) { Check.NotNull(source, nameof(source)); Check.NotNull(collectionSelector, nameof(collectionSelector)); @@ -877,7 +896,10 @@ protected override ShapedQueryExpression TranslateSelectMany(ShapedQueryExpressi /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ShapedQueryExpression TranslateSingleOrDefault( - ShapedQueryExpression source, LambdaExpression predicate, Type returnType, bool returnDefault) + ShapedQueryExpression source, + LambdaExpression predicate, + Type returnType, + bool returnDefault) { Check.NotNull(source, nameof(source)); Check.NotNull(returnType, nameof(returnType)); @@ -1067,7 +1089,8 @@ protected override ShapedQueryExpression TranslateWhere(ShapedQueryExpression so if (source.ShaperExpression is EntityShaperExpression entityShaperExpression && entityShaperExpression.EntityType.GetPartitionKeyPropertyName() != null - && TryExtractPartitionKey(predicate.Body, entityShaperExpression.EntityType, out var newPredicate) is Expression partitionKeyValue) + && TryExtractPartitionKey(predicate.Body, entityShaperExpression.EntityType, out var newPredicate) is Expression + partitionKeyValue) { var partitionKeyProperty = entityShaperExpression.EntityType.GetProperty( entityShaperExpression.EntityType.GetPartitionKeyPropertyName()); @@ -1155,12 +1178,12 @@ bool IsPartitionKeyPropertyAccess(Expression expression, IEntityType entityType) break; case MethodCallExpression methodCallExpression - when methodCallExpression.TryGetEFPropertyArguments(out _, out var propertyName): + when methodCallExpression.TryGetEFPropertyArguments(out _, out var propertyName): property = entityType.FindProperty(propertyName); break; case MethodCallExpression methodCallExpression - when methodCallExpression.TryGetIndexerArguments(_queryCompilationContext.Model, out _, out var propertyName): + when methodCallExpression.TryGetIndexerArguments(_queryCompilationContext.Model, out _, out var propertyName): property = entityType.FindProperty(propertyName); break; } @@ -1181,7 +1204,8 @@ private SqlExpression TranslateExpression(Expression expression) } private SqlExpression TranslateLambdaExpression( - ShapedQueryExpression shapedQueryExpression, LambdaExpression lambdaExpression) + ShapedQueryExpression shapedQueryExpression, + LambdaExpression lambdaExpression) { var lambdaBody = RemapLambdaBody(shapedQueryExpression.ShaperExpression, lambdaExpression); @@ -1194,7 +1218,10 @@ private static Expression RemapLambdaBody(Expression shaperBody, LambdaExpressio } private ShapedQueryExpression AggregateResultShaper( - ShapedQueryExpression source, Expression projection, bool throwOnNullResult, Type resultType) + ShapedQueryExpression source, + Expression projection, + bool throwOnNullResult, + Type resultType) { var selectExpression = (SelectExpression)source.QueryExpression; selectExpression.ReplaceProjectionMapping( diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitor.cs b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitor.cs index 147b0ee190e..9efbef8fc21 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitor.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitor.cs @@ -19,7 +19,8 @@ private sealed class CosmosProjectionBindingRemovingExpressionVisitor : CosmosPr public CosmosProjectionBindingRemovingExpressionVisitor( [NotNull] SelectExpression selectExpression, [NotNull] ParameterExpression jObjectParameter, - bool trackQueryResults) : base(jObjectParameter, trackQueryResults) + bool trackQueryResults) + : base(jObjectParameter, trackQueryResults) { _selectExpression = selectExpression; } @@ -31,7 +32,7 @@ private int GetProjectionIndex(ProjectionBindingExpression projectionBindingExpr => projectionBindingExpression.ProjectionMember != null ? (int)((ConstantExpression)_selectExpression.GetMappedProjection(projectionBindingExpression.ProjectionMember)).Value : projectionBindingExpression.Index - ?? throw new InvalidOperationException(CoreStrings.QueryFailed(projectionBindingExpression.Print(), GetType().Name)); + ?? throw new InvalidOperationException(CoreStrings.QueryFailed(projectionBindingExpression.Print(), GetType().Name)); } } } diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitorBase.cs b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitorBase.cs index f430be2d4c0..79d70940519 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitorBase.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.CosmosProjectionBindingRemovingExpressionVisitorBase.cs @@ -98,7 +98,7 @@ protected override Expression VisitBinary(BinaryExpression binaryExpression) storeName = projection.Alias; } else if (projectionExpression is UnaryExpression convertExpression - && convertExpression.NodeType == ExpressionType.Convert) + && convertExpression.NodeType == ExpressionType.Convert) { // Unwrap EntityProjectionExpression when the root entity is not projected projectionExpression = ((UnaryExpression)convertExpression.Operand).Operand; diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.InExpressionValuesExpandingExpressionVisitor.cs b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.InExpressionValuesExpandingExpressionVisitor.cs index e83674a6625..2c343cc0db3 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.InExpressionValuesExpandingExpressionVisitor.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.InExpressionValuesExpandingExpressionVisitor.cs @@ -16,7 +16,8 @@ private sealed class InExpressionValuesExpandingExpressionVisitor : ExpressionVi private readonly IReadOnlyDictionary _parametersValues; public InExpressionValuesExpandingExpressionVisitor( - ISqlExpressionFactory sqlExpressionFactory, IReadOnlyDictionary parametersValues) + ISqlExpressionFactory sqlExpressionFactory, + IReadOnlyDictionary parametersValues) { _sqlExpressionFactory = sqlExpressionFactory; _parametersValues = parametersValues; diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.QueryingEnumerable.cs b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.QueryingEnumerable.cs index fe00deabf3f..05157db529e 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.QueryingEnumerable.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.QueryingEnumerable.cs @@ -67,8 +67,11 @@ public QueryingEnumerable( public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default) => new AsyncEnumerator(this, cancellationToken); - public IEnumerator GetEnumerator() => new Enumerator(this); - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + public IEnumerator GetEnumerator() + => new Enumerator(this); + + IEnumerator IEnumerable.GetEnumerator() + => GetEnumerator(); private CosmosSqlQuery GenerateQuery() => _querySqlGeneratorFactory.Create().GetSqlQuery( @@ -127,7 +130,8 @@ public Enumerator(QueryingEnumerable queryingEnumerable) public T Current { get; private set; } - object IEnumerator.Current => Current; + object IEnumerator.Current + => Current; public bool MoveNext() { @@ -143,7 +147,7 @@ public bool MoveNext() _enumerator = _cosmosQueryContext.CosmosClient .ExecuteSqlQuery( - _selectExpression.Container, + _selectExpression.Container, _partitionKey, sqlQuery) .GetEnumerator(); @@ -174,7 +178,8 @@ public void Dispose() _enumerator = null; } - public void Reset() => throw new NotImplementedException(); + public void Reset() + => throw new NotImplementedException(); } private sealed class AsyncEnumerator : IAsyncEnumerator diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.ReadItemQueryingEnumerable.cs b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.ReadItemQueryingEnumerable.cs index eb9864d64e2..ad66807e9a7 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.ReadItemQueryingEnumerable.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.ReadItemQueryingEnumerable.cs @@ -54,9 +54,11 @@ public ReadItemQueryingEnumerable( public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default) => new Enumerator(this, cancellationToken); - public IEnumerator GetEnumerator() => new Enumerator(this); + public IEnumerator GetEnumerator() + => new Enumerator(this); - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() + => GetEnumerator(); public string ToQueryString() { @@ -163,7 +165,6 @@ private bool TryGenerateIdFromKeys(IProperty idProperty, out object value) return value != null; } - private sealed class Enumerator : IEnumerator, IAsyncEnumerator { private readonly CosmosQueryContext _cosmosQueryContext; @@ -190,7 +191,8 @@ public Enumerator(ReadItemQueryingEnumerable readItemEnumerable, Cancellation _cancellationToken = cancellationToken; } - object IEnumerator.Current => Current; + object IEnumerator.Current + => Current; public T Current { get; private set; } @@ -241,7 +243,6 @@ public async ValueTask MoveNextAsync() { if (!_hasExecuted) { - if (!_readItemEnumerable.TryGetResourceId(out var resourceId)) { throw new InvalidOperationException(CosmosStrings.ResourceIdMissing); @@ -255,10 +256,10 @@ public async ValueTask MoveNextAsync() EntityFrameworkEventSource.Log.QueryExecuting(); _item = await _cosmosQueryContext.CosmosClient.ExecuteReadItemAsync( - _readItemExpression.Container, - partitionKey, - resourceId, - _cancellationToken) + _readItemExpression.Container, + partitionKey, + resourceId, + _cancellationToken) .ConfigureAwait(false); return ShapeResult(); @@ -288,7 +289,8 @@ public ValueTask DisposeAsync() return default; } - public void Reset() => throw new NotImplementedException(); + public void Reset() + => throw new NotImplementedException(); private bool ShapeResult() { diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.cs b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.cs index b47b34af613..07a56d4df39 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.cs @@ -4,7 +4,6 @@ using System; using System.Linq.Expressions; using JetBrains.Annotations; -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Utilities; using Newtonsoft.Json.Linq; @@ -66,7 +65,8 @@ protected override Expression VisitShapedQuery(ShapedQueryExpression shapedQuery selectExpression.ApplyProjection(); shaperBody = new CosmosProjectionBindingRemovingExpressionVisitor( - selectExpression, jObjectParameter, QueryCompilationContext.QueryTrackingBehavior == QueryTrackingBehavior.TrackAll) + selectExpression, jObjectParameter, + QueryCompilationContext.QueryTrackingBehavior == QueryTrackingBehavior.TrackAll) .Visit(shaperBody); var shaperLambda = Expression.Lambda( @@ -85,12 +85,14 @@ protected override Expression VisitShapedQuery(ShapedQueryExpression shapedQuery Expression.Constant(shaperLambda.Compile()), Expression.Constant(_contextType), Expression.Constant(_partitionKeyFromExtension, typeof(string)), - Expression.Constant(QueryCompilationContext.QueryTrackingBehavior == QueryTrackingBehavior.NoTrackingWithIdentityResolution)); + Expression.Constant( + QueryCompilationContext.QueryTrackingBehavior == QueryTrackingBehavior.NoTrackingWithIdentityResolution)); case ReadItemExpression readItemExpression: shaperBody = new CosmosProjectionBindingRemovingReadItemExpressionVisitor( - readItemExpression, jObjectParameter, QueryCompilationContext.QueryTrackingBehavior == QueryTrackingBehavior.TrackAll) + readItemExpression, jObjectParameter, + QueryCompilationContext.QueryTrackingBehavior == QueryTrackingBehavior.TrackAll) .Visit(shaperBody); var shaperReadItemLambda = Expression.Lambda( @@ -106,7 +108,8 @@ protected override Expression VisitShapedQuery(ShapedQueryExpression shapedQuery Expression.Constant(readItemExpression), Expression.Constant(shaperReadItemLambda.Compile()), Expression.Constant(_contextType), - Expression.Constant(QueryCompilationContext.QueryTrackingBehavior == QueryTrackingBehavior.NoTrackingWithIdentityResolution)); + Expression.Constant( + QueryCompilationContext.QueryTrackingBehavior == QueryTrackingBehavior.NoTrackingWithIdentityResolution)); default: throw new NotImplementedException(); diff --git a/src/EFCore.Cosmos/Query/Internal/CosmosSqlTranslatingExpressionVisitor.cs b/src/EFCore.Cosmos/Query/Internal/CosmosSqlTranslatingExpressionVisitor.cs index 296b399c68b..326ef526292 100644 --- a/src/EFCore.Cosmos/Query/Internal/CosmosSqlTranslatingExpressionVisitor.cs +++ b/src/EFCore.Cosmos/Query/Internal/CosmosSqlTranslatingExpressionVisitor.cs @@ -12,7 +12,6 @@ using Microsoft.EntityFrameworkCore.Cosmos.Internal; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Storage; @@ -32,13 +31,16 @@ public class CosmosSqlTranslatingExpressionVisitor : ExpressionVisitor private static readonly MethodInfo _parameterValueExtractor = typeof(CosmosSqlTranslatingExpressionVisitor).GetTypeInfo().GetDeclaredMethod(nameof(ParameterValueExtractor)); + private static readonly MethodInfo _parameterListValueExtractor = typeof(CosmosSqlTranslatingExpressionVisitor).GetTypeInfo().GetDeclaredMethod(nameof(ParameterListValueExtractor)); private static readonly MethodInfo _concatMethodInfo = typeof(string).GetRuntimeMethod(nameof(string.Concat), new[] { typeof(object), typeof(object) }); + private static readonly MethodInfo _stringEqualsWithStringComparison = typeof(string).GetRuntimeMethod(nameof(string.Equals), new[] { typeof(string), typeof(StringComparison) }); + private static readonly MethodInfo _stringEqualsWithStringComparisonStatic = typeof(string).GetRuntimeMethod(nameof(string.Equals), new[] { typeof(string), typeof(string), typeof(StringComparison) }); @@ -184,7 +186,7 @@ protected override Expression VisitBinary(BinaryExpression binaryExpression) var visitedRight = Visit(right); if ((binaryExpression.NodeType == ExpressionType.Equal - || binaryExpression.NodeType == ExpressionType.NotEqual) + || binaryExpression.NodeType == ExpressionType.NotEqual) // Visited expression could be null, We need to pass MemberInitExpression && TryRewriteEntityEquality(binaryExpression.NodeType, visitedLeft ?? left, visitedRight ?? right, out var result)) { @@ -206,12 +208,12 @@ protected override Expression VisitBinary(BinaryExpression binaryExpression) return TranslationFailed(binaryExpression.Left, visitedLeft, out var sqlLeft) || TranslationFailed(binaryExpression.Right, visitedRight, out var sqlRight) - ? null - : _sqlExpressionFactory.MakeBinary( - uncheckedNodeTypeVariant, - sqlLeft, - sqlRight, - null); + ? null + : _sqlExpressionFactory.MakeBinary( + uncheckedNodeTypeVariant, + sqlLeft, + sqlRight, + null); static bool TryUnwrapConvertToObject(Expression expression, out Expression operand) { @@ -246,8 +248,8 @@ protected override Expression VisitConditional(ConditionalExpression conditional return TranslationFailed(conditionalExpression.Test, test, out var sqlTest) || TranslationFailed(conditionalExpression.IfTrue, ifTrue, out var sqlIfTrue) || TranslationFailed(conditionalExpression.IfFalse, ifFalse, out var sqlIfFalse) - ? null - : _sqlExpressionFactory.Condition(sqlTest, sqlIfTrue, sqlIfFalse); + ? null + : _sqlExpressionFactory.Condition(sqlTest, sqlIfTrue, sqlIfFalse); } /// @@ -298,7 +300,7 @@ protected override Expression VisitExtension(Expression extensionExpression) case ProjectionBindingExpression projectionBindingExpression: return projectionBindingExpression.ProjectionMember != null ? ((SelectExpression)projectionBindingExpression.QueryExpression) - .GetMappedProjection(projectionBindingExpression.ProjectionMember) + .GetMappedProjection(projectionBindingExpression.ProjectionMember) : null; default: @@ -312,7 +314,8 @@ protected override Expression VisitExtension(Expression extensionExpression) /// 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. /// - protected override Expression VisitInvocation(InvocationExpression invocationExpression) => null; + protected override Expression VisitInvocation(InvocationExpression invocationExpression) + => null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -320,7 +323,8 @@ protected override Expression VisitExtension(Expression extensionExpression) /// 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. /// - protected override Expression VisitLambda(Expression lambdaExpression) => null; + protected override Expression VisitLambda(Expression lambdaExpression) + => null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -328,7 +332,8 @@ protected override Expression VisitExtension(Expression extensionExpression) /// 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. /// - protected override Expression VisitListInit(ListInitExpression listInitExpression) => null; + protected override Expression VisitListInit(ListInitExpression listInitExpression) + => null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -385,10 +390,11 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp var left = Visit(methodCallExpression.Object); var right = Visit(RemoveObjectConvert(methodCallExpression.Arguments[0])); - if (TryRewriteEntityEquality(ExpressionType.Equal, - left ?? methodCallExpression.Object, - right ?? methodCallExpression.Arguments[0], - out var result)) + if (TryRewriteEntityEquality( + ExpressionType.Equal, + left ?? methodCallExpression.Object, + right ?? methodCallExpression.Arguments[0], + out var result)) { return result; } @@ -411,7 +417,8 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp var left = Visit(RemoveObjectConvert(methodCallExpression.Arguments[0])); var right = Visit(RemoveObjectConvert(methodCallExpression.Arguments[1])); - if (TryRewriteEntityEquality(ExpressionType.Equal, + if (TryRewriteEntityEquality( + ExpressionType.Equal, left ?? methodCallExpression.Arguments[0], right ?? methodCallExpression.Arguments[1], out var result)) @@ -504,9 +511,10 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp } else { - AddTranslationErrorDetails(CoreStrings.QueryUnableToTranslateMethod( - methodCallExpression.Method.DeclaringType?.DisplayName(), - methodCallExpression.Method.Name)); + AddTranslationErrorDetails( + CoreStrings.QueryUnableToTranslateMethod( + methodCallExpression.Method.DeclaringType?.DisplayName(), + methodCallExpression.Method.Name)); } } @@ -516,8 +524,8 @@ static Expression RemoveObjectConvert(Expression expression) => expression is UnaryExpression unaryExpression && (unaryExpression.NodeType == ExpressionType.Convert || unaryExpression.NodeType == ExpressionType.ConvertChecked) && unaryExpression.Type == typeof(object) - ? unaryExpression.Operand - : expression; + ? unaryExpression.Operand + : expression; } /// @@ -535,7 +543,8 @@ protected override Expression VisitNew(NewExpression newExpression) /// 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. /// - protected override Expression VisitNewArray(NewArrayExpression newArrayExpression) => null; + protected override Expression VisitNewArray(NewArrayExpression newArrayExpression) + => null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -619,7 +628,8 @@ protected override Expression VisitTypeBinary(TypeBinaryExpression typeBinaryExp var derivedType = entityType.GetDerivedTypes().SingleOrDefault(et => et.ClrType == typeBinaryExpression.TypeOperand); if (derivedType != null - && TryBindMember(entityReferenceExpression, + && TryBindMember( + entityReferenceExpression, MemberIdentity.Create(entityType.GetDiscriminatorProperty().Name)) is SqlExpression discriminatorColumn) { var concreteEntityTypes = derivedType.GetConcreteDerivedTypesInclusive().ToList(); @@ -646,8 +656,10 @@ private Expression TryBindMember(Expression source, MemberIdentity member) } var result = member.MemberInfo != null - ? entityReferenceExpression.ParameterEntity.BindMember(member.MemberInfo, entityReferenceExpression.Type, clientEval: false, out _) - : entityReferenceExpression.ParameterEntity.BindMember(member.Name, entityReferenceExpression.Type, clientEval: false, out _); + ? entityReferenceExpression.ParameterEntity.BindMember( + member.MemberInfo, entityReferenceExpression.Type, clientEval: false, out _) + : entityReferenceExpression.ParameterEntity.BindMember( + member.Name, entityReferenceExpression.Type, clientEval: false, out _); if (result == null) { @@ -661,7 +673,7 @@ private Expression TryBindMember(Expression source, MemberIdentity member) { EntityProjectionExpression entityProjectionExpression => new EntityReferenceExpression(entityProjectionExpression), ObjectArrayProjectionExpression objectArrayProjectionExpression - => new EntityReferenceExpression(objectArrayProjectionExpression.InnerProjection), + => new EntityReferenceExpression(objectArrayProjectionExpression.InnerProjection), _ => result }; } @@ -723,7 +735,8 @@ private bool TryRewriteContainsEntity(Expression source, Expression item, out Ex { case SqlConstantExpression sqlConstantExpression: var values = (IEnumerable)sqlConstantExpression.Value; - var propertyValueList = (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(property.ClrType.MakeNullable())); + var propertyValueList = + (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(property.ClrType.MakeNullable())); var propertyGetter = property.GetGetter(); foreach (var value in values) { @@ -734,7 +747,7 @@ private bool TryRewriteContainsEntity(Expression source, Expression item, out Ex break; case SqlParameterExpression sqlParameterExpression - when sqlParameterExpression.Name.StartsWith(QueryCompilationContext.QueryParameterPrefix, StringComparison.Ordinal): + when sqlParameterExpression.Name.StartsWith(QueryCompilationContext.QueryParameterPrefix, StringComparison.Ordinal): var lambda = Expression.Lambda( Expression.Call( _parameterListValueExtractor.MakeGenericMethod(entityType.ClrType, property.ClrType.MakeNullable()), @@ -745,8 +758,8 @@ when sqlParameterExpression.Name.StartsWith(QueryCompilationContext.QueryParamet ); var newParameterName = - $"{_runtimeParameterPrefix}" + - $"{sqlParameterExpression.Name.Substring(QueryCompilationContext.QueryParameterPrefix.Length)}_{property.Name}"; + $"{_runtimeParameterPrefix}" + + $"{sqlParameterExpression.Name.Substring(QueryCompilationContext.QueryParameterPrefix.Length)}_{property.Name}"; rewrittenSource = _queryCompilationContext.RegisterRuntimeParameter(newParameterName, lambda); break; @@ -755,10 +768,11 @@ when sqlParameterExpression.Name.StartsWith(QueryCompilationContext.QueryParamet return false; } - result = Visit(Expression.Call( - EnumerableMethods.Contains.MakeGenericMethod(property.ClrType.MakeNullable()), - rewrittenSource, - CreatePropertyAccessExpression(item, property))); + result = Visit( + Expression.Call( + EnumerableMethods.Contains.MakeGenericMethod(property.ClrType.MakeNullable()), + rewrittenSource, + CreatePropertyAccessExpression(item, property))); return true; } @@ -786,10 +800,13 @@ private bool TryRewriteEntityEquality(ExpressionType nodeType, Expression left, throw new InvalidOperationException(CoreStrings.EntityEqualityOnKeylessEntityNotSupported(entityType1.DisplayName())); } - result = Visit(primaryKeyProperties1.Select(p => - Expression.MakeBinary( - nodeType, CreatePropertyAccessExpression(nonNullEntityReference, p), Expression.Constant(null, p.ClrType.MakeNullable()))) - .Aggregate((l, r) => nodeType == ExpressionType.Equal ? Expression.OrElse(l, r) : Expression.AndAlso(l, r))); + result = Visit( + primaryKeyProperties1.Select( + p => + Expression.MakeBinary( + nodeType, CreatePropertyAccessExpression(nonNullEntityReference, p), + Expression.Constant(null, p.ClrType.MakeNullable()))) + .Aggregate((l, r) => nodeType == ExpressionType.Equal ? Expression.OrElse(l, r) : Expression.AndAlso(l, r))); return true; } @@ -814,11 +831,13 @@ private bool TryRewriteEntityEquality(ExpressionType nodeType, Expression left, throw new InvalidOperationException(CoreStrings.EntityEqualityOnKeylessEntityNotSupported(entityType.DisplayName())); } - result = Visit(primaryKeyProperties.Select(p => - Expression.MakeBinary( - nodeType, - CreatePropertyAccessExpression(left, p), - CreatePropertyAccessExpression(right, p))) + result = Visit( + primaryKeyProperties.Select( + p => + Expression.MakeBinary( + nodeType, + CreatePropertyAccessExpression(left, p), + CreatePropertyAccessExpression(right, p))) .Aggregate((l, r) => Expression.AndAlso(l, r))); return true; @@ -833,7 +852,7 @@ private Expression CreatePropertyAccessExpression(Expression target, IProperty p property.GetGetter().GetClrValue(sqlConstantExpression.Value), property.ClrType.MakeNullable()); case SqlParameterExpression sqlParameterExpression - when sqlParameterExpression.Name.StartsWith(QueryCompilationContext.QueryParameterPrefix, StringComparison.Ordinal): + when sqlParameterExpression.Name.StartsWith(QueryCompilationContext.QueryParameterPrefix, StringComparison.Ordinal): var lambda = Expression.Lambda( Expression.Call( _parameterValueExtractor.MakeGenericMethod(property.ClrType.MakeNullable()), @@ -843,14 +862,14 @@ when sqlParameterExpression.Name.StartsWith(QueryCompilationContext.QueryParamet QueryCompilationContext.QueryContextParameter); var newParameterName = - $"{_runtimeParameterPrefix}" + - $"{sqlParameterExpression.Name.Substring(QueryCompilationContext.QueryParameterPrefix.Length)}_{property.Name}"; + $"{_runtimeParameterPrefix}" + + $"{sqlParameterExpression.Name.Substring(QueryCompilationContext.QueryParameterPrefix.Length)}_{property.Name}"; return _queryCompilationContext.RegisterRuntimeParameter(newParameterName, lambda); case MemberInitExpression memberInitExpression - when memberInitExpression.Bindings.SingleOrDefault( - mb => mb.Member.Name == property.Name) is MemberAssignment memberAssignment: + when memberInitExpression.Bindings.SingleOrDefault( + mb => mb.Member.Name == property.Name) is MemberAssignment memberAssignment: return memberAssignment.Expression; default: @@ -865,7 +884,9 @@ private static T ParameterValueExtractor(QueryContext context, string basePar } private static List ParameterListValueExtractor( - QueryContext context, string baseParameterName, IProperty property) + QueryContext context, + string baseParameterName, + IProperty property) { if (!(context.ParameterValues[baseParameterName] is IEnumerable baseListParameter)) { @@ -902,8 +923,8 @@ private static bool CanEvaluate(Expression expression) case MemberInitExpression memberInitExpression: return CanEvaluate(memberInitExpression.NewExpression) - && memberInitExpression.Bindings.All( - mb => mb is MemberAssignment memberAssignment && CanEvaluate(memberAssignment.Expression)); + && memberInitExpression.Bindings.All( + mb => mb is MemberAssignment memberAssignment && CanEvaluate(memberAssignment.Expression)); default: return false; @@ -944,14 +965,16 @@ private EntityReferenceExpression(EntityProjectionExpression parameter, Type typ public IEntityType EntityType { get; } public override Type Type { get; } - public override ExpressionType NodeType => ExpressionType.Extension; + + public override ExpressionType NodeType + => ExpressionType.Extension; public Expression Convert(Type type) { return type == typeof(object) // Ignore object conversion || type.IsAssignableFrom(Type) // Ignore conversion to base/interface - ? this - : new EntityReferenceExpression(ParameterEntity, type); + ? this + : new EntityReferenceExpression(ParameterEntity, type); } } diff --git a/src/EFCore.Cosmos/Query/Internal/EntityProjectionExpression.cs b/src/EFCore.Cosmos/Query/Internal/EntityProjectionExpression.cs index aba843e795a..6ee34818703 100644 --- a/src/EFCore.Cosmos/Query/Internal/EntityProjectionExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/EntityProjectionExpression.cs @@ -8,8 +8,8 @@ using System.Reflection; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Cosmos.Internal; -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Metadata.Conventions; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Utilities; @@ -48,7 +48,8 @@ public EntityProjectionExpression([NotNull] IEntityType entityType, [NotNull] Ex /// 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 sealed override ExpressionType NodeType => ExpressionType.Extension; + public sealed override ExpressionType NodeType + => ExpressionType.Extension; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -56,7 +57,8 @@ public EntityProjectionExpression([NotNull] IEntityType entityType, [NotNull] Ex /// 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 override Type Type => EntityType.ClrType; + public override Type Type + => EntityType.ClrType; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -130,7 +132,7 @@ public virtual Expression BindProperty([NotNull] IProperty property, bool client if (!clientEval // TODO: Remove once __jObject is translated to the access root in a better fashion and // would not otherwise be found to be non-translatable. See issues #17670 and #14121. - && property.Name != EntityFrameworkCore.Metadata.Conventions.StoreKeyConvention.JObjectPropertyName + && property.Name != StoreKeyConvention.JObjectPropertyName && expression.Name.Length == 0) { // Non-persisted property can't be translated @@ -183,7 +185,10 @@ public virtual Expression BindNavigation([NotNull] INavigation navigation, bool /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual Expression BindMember( - [NotNull] string name, [NotNull] Type entityType, bool clientEval, [NotNull] out IPropertyBase propertyBase) + [NotNull] string name, + [NotNull] Type entityType, + bool clientEval, + [NotNull] out IPropertyBase propertyBase) => BindMember(MemberIdentity.Create(name), entityType, clientEval, out propertyBase); /// @@ -193,7 +198,10 @@ public virtual Expression BindMember( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual Expression BindMember( - [NotNull] MemberInfo memberInfo, [NotNull] Type entityType, bool clientEval, [NotNull] out IPropertyBase propertyBase) + [NotNull] MemberInfo memberInfo, + [NotNull] Type entityType, + bool clientEval, + [NotNull] out IPropertyBase propertyBase) => BindMember(MemberIdentity.Create(memberInfo), entityType, clientEval, out propertyBase); private Expression BindMember(MemberIdentity member, Type entityClrType, bool clientEval, out IPropertyBase propertyBase) @@ -240,8 +248,9 @@ public virtual EntityProjectionExpression UpdateEntityType([NotNull] IEntityType if (!derivedType.GetAllBaseTypes().Contains(EntityType)) { - throw new InvalidOperationException(CosmosStrings.InvalidDerivedTypeInEntityProjection( - derivedType.DisplayName(), EntityType.DisplayName())); + throw new InvalidOperationException( + CosmosStrings.InvalidDerivedTypeInEntityProjection( + derivedType.DisplayName(), EntityType.DisplayName())); } return new EntityProjectionExpression(derivedType, AccessExpression); @@ -268,13 +277,13 @@ void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) /// public override bool Equals(object obj) => obj != null - && (ReferenceEquals(this, obj) - || obj is EntityProjectionExpression entityProjectionExpression - && Equals(entityProjectionExpression)); + && (ReferenceEquals(this, obj) + || obj is EntityProjectionExpression entityProjectionExpression + && Equals(entityProjectionExpression)); private bool Equals(EntityProjectionExpression entityProjectionExpression) => Equals(EntityType, entityProjectionExpression.EntityType) - && AccessExpression.Equals(entityProjectionExpression.AccessExpression); + && AccessExpression.Equals(entityProjectionExpression.AccessExpression); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -282,6 +291,7 @@ private bool Equals(EntityProjectionExpression entityProjectionExpression) /// 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 override int GetHashCode() => HashCode.Combine(EntityType, AccessExpression); + public override int GetHashCode() + => HashCode.Combine(EntityType, AccessExpression); } } diff --git a/src/EFCore.Cosmos/Query/Internal/EqualsTranslator.cs b/src/EFCore.Cosmos/Query/Internal/EqualsTranslator.cs index f7104d9d436..2ce9b9713e0 100644 --- a/src/EFCore.Cosmos/Query/Internal/EqualsTranslator.cs +++ b/src/EFCore.Cosmos/Query/Internal/EqualsTranslator.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Linq.Expressions; using System.Reflection; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Diagnostics; @@ -39,7 +38,10 @@ public EqualsTranslator([NotNull] ISqlExpressionFactory sqlExpressionFactory) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) + SqlExpression instance, + MethodInfo method, + IReadOnlyList arguments, + IDiagnosticsLogger logger) { Check.NotNull(method, nameof(method)); Check.NotNull(arguments, nameof(arguments)); @@ -56,8 +58,8 @@ public virtual SqlExpression Translate( right = arguments[0]; } else if (instance == null - && method.Name == nameof(object.Equals) - && arguments.Count == 2) + && method.Name == nameof(object.Equals) + && arguments.Count == 2) { left = arguments[0]; right = arguments[1]; @@ -67,10 +69,10 @@ public virtual SqlExpression Translate( && right != null) { return left.Type.UnwrapNullableType() == right.Type.UnwrapNullableType() - || (right.Type == typeof(object) && right is SqlParameterExpression) - || (left.Type == typeof(object) && left is SqlParameterExpression) - ? _sqlExpressionFactory.Equal(left, right) - : (SqlExpression)_sqlExpressionFactory.Constant(false); + || (right.Type == typeof(object) && right is SqlParameterExpression) + || (left.Type == typeof(object) && left is SqlParameterExpression) + ? _sqlExpressionFactory.Equal(left, right) + : (SqlExpression)_sqlExpressionFactory.Constant(false); } return null; diff --git a/src/EFCore.Cosmos/Query/Internal/IMemberTranslator.cs b/src/EFCore.Cosmos/Query/Internal/IMemberTranslator.cs index 01d4d7291e4..556e3cdebb3 100644 --- a/src/EFCore.Cosmos/Query/Internal/IMemberTranslator.cs +++ b/src/EFCore.Cosmos/Query/Internal/IMemberTranslator.cs @@ -22,7 +22,10 @@ public interface IMemberTranslator /// 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. /// - SqlExpression Translate([NotNull] SqlExpression instance, [NotNull] MemberInfo member, [NotNull] Type returnType, + SqlExpression Translate( + [NotNull] SqlExpression instance, + [NotNull] MemberInfo member, + [NotNull] Type returnType, [NotNull] IDiagnosticsLogger logger); } } diff --git a/src/EFCore.Cosmos/Query/Internal/IMemberTranslatorProvider.cs b/src/EFCore.Cosmos/Query/Internal/IMemberTranslatorProvider.cs index 86ab4caa381..b4d9cbef372 100644 --- a/src/EFCore.Cosmos/Query/Internal/IMemberTranslatorProvider.cs +++ b/src/EFCore.Cosmos/Query/Internal/IMemberTranslatorProvider.cs @@ -22,7 +22,10 @@ public interface IMemberTranslatorProvider /// 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. /// - SqlExpression Translate([NotNull] SqlExpression instance, [NotNull] MemberInfo member, [NotNull] Type returnType, + SqlExpression Translate( + [NotNull] SqlExpression instance, + [NotNull] MemberInfo member, + [NotNull] Type returnType, [NotNull] IDiagnosticsLogger logger); } } diff --git a/src/EFCore.Cosmos/Query/Internal/IMethodCallTranslator.cs b/src/EFCore.Cosmos/Query/Internal/IMethodCallTranslator.cs index a0b323f9388..230f612abb4 100644 --- a/src/EFCore.Cosmos/Query/Internal/IMethodCallTranslator.cs +++ b/src/EFCore.Cosmos/Query/Internal/IMethodCallTranslator.cs @@ -23,7 +23,9 @@ public interface IMethodCallTranslator /// doing so can result in application failures when updating to a new Entity Framework Core release. /// SqlExpression Translate( - [CanBeNull] SqlExpression instance, [NotNull] MethodInfo method, [NotNull] IReadOnlyList arguments, + [CanBeNull] SqlExpression instance, + [NotNull] MethodInfo method, + [NotNull] IReadOnlyList arguments, [NotNull] IDiagnosticsLogger logger); } } diff --git a/src/EFCore.Cosmos/Query/Internal/ISqlExpressionFactory.cs b/src/EFCore.Cosmos/Query/Internal/ISqlExpressionFactory.cs index a8ff2add268..a245b2bad6a 100644 --- a/src/EFCore.Cosmos/Query/Internal/ISqlExpressionFactory.cs +++ b/src/EFCore.Cosmos/Query/Internal/ISqlExpressionFactory.cs @@ -125,7 +125,9 @@ SqlBinaryExpression MakeBinary( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// SqlBinaryExpression Add( - [NotNull] SqlExpression left, [NotNull] SqlExpression right, [CanBeNull] CoreTypeMapping typeMapping = null); + [NotNull] SqlExpression left, + [NotNull] SqlExpression right, + [CanBeNull] CoreTypeMapping typeMapping = null); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -134,7 +136,9 @@ SqlBinaryExpression Add( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// SqlBinaryExpression Subtract( - [NotNull] SqlExpression left, [NotNull] SqlExpression right, [CanBeNull] CoreTypeMapping typeMapping = null); + [NotNull] SqlExpression left, + [NotNull] SqlExpression right, + [CanBeNull] CoreTypeMapping typeMapping = null); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -143,7 +147,9 @@ SqlBinaryExpression Subtract( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// SqlBinaryExpression Multiply( - [NotNull] SqlExpression left, [NotNull] SqlExpression right, [CanBeNull] CoreTypeMapping typeMapping = null); + [NotNull] SqlExpression left, + [NotNull] SqlExpression right, + [CanBeNull] CoreTypeMapping typeMapping = null); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -152,7 +158,9 @@ SqlBinaryExpression Multiply( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// SqlBinaryExpression Divide( - [NotNull] SqlExpression left, [NotNull] SqlExpression right, [CanBeNull] CoreTypeMapping typeMapping = null); + [NotNull] SqlExpression left, + [NotNull] SqlExpression right, + [CanBeNull] CoreTypeMapping typeMapping = null); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -161,7 +169,9 @@ SqlBinaryExpression Divide( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// SqlBinaryExpression Modulo( - [NotNull] SqlExpression left, [NotNull] SqlExpression right, [CanBeNull] CoreTypeMapping typeMapping = null); + [NotNull] SqlExpression left, + [NotNull] SqlExpression right, + [CanBeNull] CoreTypeMapping typeMapping = null); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -170,7 +180,9 @@ SqlBinaryExpression Modulo( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// SqlBinaryExpression And( - [NotNull] SqlExpression left, [NotNull] SqlExpression right, [CanBeNull] CoreTypeMapping typeMapping = null); + [NotNull] SqlExpression left, + [NotNull] SqlExpression right, + [CanBeNull] CoreTypeMapping typeMapping = null); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -179,7 +191,9 @@ SqlBinaryExpression And( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// SqlBinaryExpression Or( - [NotNull] SqlExpression left, [NotNull] SqlExpression right, [CanBeNull] CoreTypeMapping typeMapping = null); + [NotNull] SqlExpression left, + [NotNull] SqlExpression right, + [CanBeNull] CoreTypeMapping typeMapping = null); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -204,7 +218,9 @@ SqlBinaryExpression Or( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// SqlUnaryExpression Convert( - [NotNull] SqlExpression operand, [NotNull] Type type, [CanBeNull] CoreTypeMapping typeMapping = null); + [NotNull] SqlExpression operand, + [NotNull] Type type, + [CanBeNull] CoreTypeMapping typeMapping = null); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -241,7 +257,9 @@ SqlFunctionExpression Function( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// SqlConditionalExpression Condition( - [NotNull] SqlExpression test, [NotNull] SqlExpression ifTrue, [NotNull] SqlExpression ifFalse); + [NotNull] SqlExpression test, + [NotNull] SqlExpression ifTrue, + [NotNull] SqlExpression ifFalse); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Cosmos/Query/Internal/InExpression.cs b/src/EFCore.Cosmos/Query/Internal/InExpression.cs index 2e613a510d5..0870340991b 100644 --- a/src/EFCore.Cosmos/Query/Internal/InExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/InExpression.cs @@ -25,7 +25,10 @@ public class InExpression : SqlExpression /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public InExpression( - [NotNull] SqlExpression item, bool negated, [NotNull] SqlExpression values, [NotNull] CoreTypeMapping typeMapping) + [NotNull] SqlExpression item, + bool negated, + [NotNull] SqlExpression values, + [NotNull] CoreTypeMapping typeMapping) : base(typeof(bool), typeMapping) { Item = item; @@ -77,7 +80,8 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// 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 virtual InExpression Negate() => new InExpression(Item, !IsNegated, Values, TypeMapping); + public virtual InExpression Negate() + => new InExpression(Item, !IsNegated, Values, TypeMapping); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -115,15 +119,15 @@ protected override void Print(ExpressionPrinter expressionPrinter) /// public override bool Equals(object obj) => obj != null - && (ReferenceEquals(this, obj) - || obj is InExpression inExpression - && Equals(inExpression)); + && (ReferenceEquals(this, obj) + || obj is InExpression inExpression + && Equals(inExpression)); private bool Equals(InExpression inExpression) => base.Equals(inExpression) - && Item.Equals(inExpression.Item) - && IsNegated.Equals(inExpression.IsNegated) - && (Values == null ? inExpression.Values == null : Values.Equals(inExpression.Values)); + && Item.Equals(inExpression.Item) + && IsNegated.Equals(inExpression.IsNegated) + && (Values == null ? inExpression.Values == null : Values.Equals(inExpression.Values)); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -131,6 +135,7 @@ private bool Equals(InExpression inExpression) /// 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 override int GetHashCode() => HashCode.Combine(base.GetHashCode(), Item, IsNegated, Values); + public override int GetHashCode() + => HashCode.Combine(base.GetHashCode(), Item, IsNegated, Values); } } diff --git a/src/EFCore.Cosmos/Query/Internal/KeyAccessExpression.cs b/src/EFCore.Cosmos/Query/Internal/KeyAccessExpression.cs index 097af897885..431f8e22789 100644 --- a/src/EFCore.Cosmos/Query/Internal/KeyAccessExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/KeyAccessExpression.cs @@ -101,11 +101,12 @@ protected override void Print(ExpressionPrinter expressionPrinter) /// 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 override string ToString() => Name?.Length > 0 - ? $"{AccessExpression}[\"{Name}\"]" - // TODO: Remove once __jObject is translated to the access root in a better fashion. - // See issue #17670 and related issue #14121. - : $"{AccessExpression}"; + public override string ToString() + => Name?.Length > 0 + ? $"{AccessExpression}[\"{Name}\"]" + // TODO: Remove once __jObject is translated to the access root in a better fashion. + // See issue #17670 and related issue #14121. + : $"{AccessExpression}"; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -115,14 +116,14 @@ public override string ToString() => Name?.Length > 0 /// public override bool Equals(object obj) => obj != null - && (ReferenceEquals(this, obj) - || obj is KeyAccessExpression keyAccessExpression - && Equals(keyAccessExpression)); + && (ReferenceEquals(this, obj) + || obj is KeyAccessExpression keyAccessExpression + && Equals(keyAccessExpression)); private bool Equals(KeyAccessExpression keyAccessExpression) => base.Equals(keyAccessExpression) - && string.Equals(Name, keyAccessExpression.Name) - && AccessExpression.Equals(keyAccessExpression.AccessExpression); + && string.Equals(Name, keyAccessExpression.Name) + && AccessExpression.Equals(keyAccessExpression.AccessExpression); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -130,6 +131,7 @@ private bool Equals(KeyAccessExpression keyAccessExpression) /// 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 override int GetHashCode() => HashCode.Combine(base.GetHashCode(), Name, AccessExpression); + public override int GetHashCode() + => HashCode.Combine(base.GetHashCode(), Name, AccessExpression); } } diff --git a/src/EFCore.Cosmos/Query/Internal/ObjectAccessExpression.cs b/src/EFCore.Cosmos/Query/Internal/ObjectAccessExpression.cs index 1b61f498c10..fdaf4466bc0 100644 --- a/src/EFCore.Cosmos/Query/Internal/ObjectAccessExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/ObjectAccessExpression.cs @@ -45,7 +45,8 @@ public ObjectAccessExpression([NotNull] INavigation navigation, [NotNull] Expres /// 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 override ExpressionType NodeType => ExpressionType.Extension; + public override ExpressionType NodeType + => ExpressionType.Extension; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -53,7 +54,8 @@ public ObjectAccessExpression([NotNull] INavigation navigation, [NotNull] Expres /// 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 override Type Type => Navigation.ClrType; + public override Type Type + => Navigation.ClrType; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -122,7 +124,8 @@ void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) /// 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 override string ToString() => $"{AccessExpression}[\"{Name}\"]"; + public override string ToString() + => $"{AccessExpression}[\"{Name}\"]"; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -132,13 +135,13 @@ void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) /// public override bool Equals(object obj) => obj != null - && (ReferenceEquals(this, obj) - || obj is ObjectAccessExpression objectAccessExpression - && Equals(objectAccessExpression)); + && (ReferenceEquals(this, obj) + || obj is ObjectAccessExpression objectAccessExpression + && Equals(objectAccessExpression)); private bool Equals(ObjectAccessExpression objectAccessExpression) => Navigation == objectAccessExpression.Navigation - && AccessExpression.Equals(objectAccessExpression.AccessExpression); + && AccessExpression.Equals(objectAccessExpression.AccessExpression); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -146,6 +149,7 @@ private bool Equals(ObjectAccessExpression objectAccessExpression) /// 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 override int GetHashCode() => HashCode.Combine(Navigation, AccessExpression); + public override int GetHashCode() + => HashCode.Combine(Navigation, AccessExpression); } } diff --git a/src/EFCore.Cosmos/Query/Internal/ObjectArrayProjectionExpression.cs b/src/EFCore.Cosmos/Query/Internal/ObjectArrayProjectionExpression.cs index cf04b3835ab..d1e52e733c1 100644 --- a/src/EFCore.Cosmos/Query/Internal/ObjectArrayProjectionExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/ObjectArrayProjectionExpression.cs @@ -44,9 +44,10 @@ public ObjectArrayProjectionExpression( Navigation = navigation; AccessExpression = accessExpression; - InnerProjection = innerProjection ?? new EntityProjectionExpression( - targetType, - new RootReferenceExpression(targetType, "")); + InnerProjection = innerProjection + ?? new EntityProjectionExpression( + targetType, + new RootReferenceExpression(targetType, "")); } /// @@ -55,7 +56,8 @@ public ObjectArrayProjectionExpression( /// 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 sealed override ExpressionType NodeType => ExpressionType.Extension; + public sealed override ExpressionType NodeType + => ExpressionType.Extension; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -120,7 +122,8 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual ObjectArrayProjectionExpression Update( - [NotNull] Expression accessExpression, [NotNull] EntityProjectionExpression innerProjection) + [NotNull] Expression accessExpression, + [NotNull] EntityProjectionExpression innerProjection) => accessExpression != AccessExpression || innerProjection != InnerProjection ? new ObjectArrayProjectionExpression(Navigation, accessExpression, innerProjection) : this; @@ -144,7 +147,8 @@ void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) /// 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 override string ToString() => $"{AccessExpression}[\"{Name}\"]"; + public override string ToString() + => $"{AccessExpression}[\"{Name}\"]"; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -154,13 +158,13 @@ void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) /// public override bool Equals(object obj) => obj != null - && (ReferenceEquals(this, obj) - || obj is ObjectArrayProjectionExpression arrayProjectionExpression - && Equals(arrayProjectionExpression)); + && (ReferenceEquals(this, obj) + || obj is ObjectArrayProjectionExpression arrayProjectionExpression + && Equals(arrayProjectionExpression)); private bool Equals(ObjectArrayProjectionExpression objectArrayProjectionExpression) => AccessExpression.Equals(objectArrayProjectionExpression.AccessExpression) - && InnerProjection.Equals(objectArrayProjectionExpression.InnerProjection); + && InnerProjection.Equals(objectArrayProjectionExpression.InnerProjection); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -168,6 +172,7 @@ private bool Equals(ObjectArrayProjectionExpression objectArrayProjectionExpress /// 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 override int GetHashCode() => HashCode.Combine(AccessExpression, InnerProjection); + public override int GetHashCode() + => HashCode.Combine(AccessExpression, InnerProjection); } } diff --git a/src/EFCore.Cosmos/Query/Internal/OrderingExpression.cs b/src/EFCore.Cosmos/Query/Internal/OrderingExpression.cs index fcc3a6320f2..016ef5dfa79 100644 --- a/src/EFCore.Cosmos/Query/Internal/OrderingExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/OrderingExpression.cs @@ -51,7 +51,8 @@ public OrderingExpression([NotNull] SqlExpression expression, bool ascending) /// 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 sealed override ExpressionType NodeType => ExpressionType.Extension; + public sealed override ExpressionType NodeType + => ExpressionType.Extension; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -59,7 +60,8 @@ public OrderingExpression([NotNull] SqlExpression expression, bool ascending) /// 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 override Type Type => Expression.Type; + public override Type Type + => Expression.Type; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -108,13 +110,13 @@ void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) /// public override bool Equals(object obj) => obj != null - && (ReferenceEquals(this, obj) - || obj is OrderingExpression orderingExpression - && Equals(orderingExpression)); + && (ReferenceEquals(this, obj) + || obj is OrderingExpression orderingExpression + && Equals(orderingExpression)); private bool Equals(OrderingExpression orderingExpression) => Expression.Equals(orderingExpression.Expression) - && IsAscending == orderingExpression.IsAscending; + && IsAscending == orderingExpression.IsAscending; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -122,6 +124,7 @@ private bool Equals(OrderingExpression orderingExpression) /// 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 override int GetHashCode() => HashCode.Combine(Expression, IsAscending); + public override int GetHashCode() + => HashCode.Combine(Expression, IsAscending); } } diff --git a/src/EFCore.Cosmos/Query/Internal/ProjectionExpression.cs b/src/EFCore.Cosmos/Query/Internal/ProjectionExpression.cs index 6ae428716f5..c2d029fb525 100644 --- a/src/EFCore.Cosmos/Query/Internal/ProjectionExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/ProjectionExpression.cs @@ -60,7 +60,8 @@ public virtual string Name /// 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 override Type Type => Expression.Type; + public override Type Type + => Expression.Type; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -68,7 +69,8 @@ public virtual string Name /// 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 sealed override ExpressionType NodeType => ExpressionType.Extension; + public sealed override ExpressionType NodeType + => ExpressionType.Extension; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -120,13 +122,13 @@ void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) /// public override bool Equals(object obj) => obj != null - && (ReferenceEquals(this, obj) - || obj is ProjectionExpression projectionExpression - && Equals(projectionExpression)); + && (ReferenceEquals(this, obj) + || obj is ProjectionExpression projectionExpression + && Equals(projectionExpression)); private bool Equals(ProjectionExpression projectionExpression) => string.Equals(Alias, projectionExpression.Alias) - && Expression.Equals(projectionExpression.Expression); + && Expression.Equals(projectionExpression.Expression); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -134,6 +136,7 @@ private bool Equals(ProjectionExpression projectionExpression) /// 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 override int GetHashCode() => HashCode.Combine(Alias, Expression); + public override int GetHashCode() + => HashCode.Combine(Alias, Expression); } } diff --git a/src/EFCore.Cosmos/Query/Internal/QuerySqlGenerator.cs b/src/EFCore.Cosmos/Query/Internal/QuerySqlGenerator.cs index 51958a2d5eb..0b6082c4d07 100644 --- a/src/EFCore.Cosmos/Query/Internal/QuerySqlGenerator.cs +++ b/src/EFCore.Cosmos/Query/Internal/QuerySqlGenerator.cs @@ -70,7 +70,8 @@ public class QuerySqlGenerator : SqlExpressionVisitor /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual CosmosSqlQuery GetSqlQuery( - [NotNull] SelectExpression selectExpression, [NotNull] IReadOnlyDictionary parameterValues) + [NotNull] SelectExpression selectExpression, + [NotNull] IReadOnlyDictionary parameterValues) { _sqlBuilder.Clear(); _parameterValues = parameterValues; diff --git a/src/EFCore.Cosmos/Query/Internal/QuerySqlGeneratorFactory.cs b/src/EFCore.Cosmos/Query/Internal/QuerySqlGeneratorFactory.cs index 7d89de2e6c4..1bbb56ca865 100644 --- a/src/EFCore.Cosmos/Query/Internal/QuerySqlGeneratorFactory.cs +++ b/src/EFCore.Cosmos/Query/Internal/QuerySqlGeneratorFactory.cs @@ -17,6 +17,7 @@ public class QuerySqlGeneratorFactory : IQuerySqlGeneratorFactory /// 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 virtual QuerySqlGenerator Create() => new QuerySqlGenerator(); + public virtual QuerySqlGenerator Create() + => new QuerySqlGenerator(); } } diff --git a/src/EFCore.Cosmos/Query/Internal/ReadItemExpression.cs b/src/EFCore.Cosmos/Query/Internal/ReadItemExpression.cs index 570e6df23f2..fc9eb8383fe 100644 --- a/src/EFCore.Cosmos/Query/Internal/ReadItemExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/ReadItemExpression.cs @@ -7,7 +7,6 @@ using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Utilities; -using Newtonsoft.Json.Linq; namespace Microsoft.EntityFrameworkCore.Cosmos.Query.Internal { @@ -27,7 +26,8 @@ public class ReadItemExpression : Expression /// 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 override Type Type => typeof(object); + public override Type Type + => typeof(object); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -35,7 +35,8 @@ public class ReadItemExpression : Expression /// 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 override ExpressionType NodeType => ExpressionType.Extension; + public override ExpressionType NodeType + => ExpressionType.Extension; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Cosmos/Query/Internal/RootReferenceExpression.cs b/src/EFCore.Cosmos/Query/Internal/RootReferenceExpression.cs index bb0bfdfcf21..7ebf7f23dbf 100644 --- a/src/EFCore.Cosmos/Query/Internal/RootReferenceExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/RootReferenceExpression.cs @@ -35,7 +35,8 @@ public RootReferenceExpression([NotNull] IEntityType entityType, [NotNull] strin /// 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 sealed override ExpressionType NodeType => ExpressionType.Extension; + public sealed override ExpressionType NodeType + => ExpressionType.Extension; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -43,7 +44,8 @@ public RootReferenceExpression([NotNull] IEntityType entityType, [NotNull] strin /// 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 override Type Type => EntityType.ClrType; + public override Type Type + => EntityType.ClrType; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -67,7 +69,8 @@ public RootReferenceExpression([NotNull] IEntityType entityType, [NotNull] strin /// 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. /// - string IAccessExpression.Name => Alias; + string IAccessExpression.Name + => Alias; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -88,7 +91,8 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// 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 override string ToString() => Alias; + public override string ToString() + => Alias; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -98,13 +102,13 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// public override bool Equals(object obj) => obj != null - && (ReferenceEquals(this, obj) - || obj is RootReferenceExpression rootReferenceExpression - && Equals(rootReferenceExpression)); + && (ReferenceEquals(this, obj) + || obj is RootReferenceExpression rootReferenceExpression + && Equals(rootReferenceExpression)); private bool Equals(RootReferenceExpression rootReferenceExpression) => string.Equals(Alias, rootReferenceExpression.Alias) - && EntityType.Equals(rootReferenceExpression.EntityType); + && EntityType.Equals(rootReferenceExpression.EntityType); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -112,6 +116,7 @@ private bool Equals(RootReferenceExpression rootReferenceExpression) /// 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 override int GetHashCode() => HashCode.Combine(Alias, EntityType); + public override int GetHashCode() + => HashCode.Combine(Alias, EntityType); } } diff --git a/src/EFCore.Cosmos/Query/Internal/SelectExpression.cs b/src/EFCore.Cosmos/Query/Internal/SelectExpression.cs index e96224f2930..cae99b0795c 100644 --- a/src/EFCore.Cosmos/Query/Internal/SelectExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/SelectExpression.cs @@ -84,7 +84,8 @@ private SelectExpression( /// 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 virtual IReadOnlyList Projection => _projection; + public virtual IReadOnlyList Projection + => _projection; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -100,7 +101,8 @@ private SelectExpression( /// 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 virtual IReadOnlyList Orderings => _orderings; + public virtual IReadOnlyList Orderings + => _orderings; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -143,7 +145,6 @@ private SelectExpression( public virtual Expression GetMappedProjection([NotNull] ProjectionMember projectionMember) => _projectionMapping[projectionMember]; - /// /// 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 @@ -170,12 +171,11 @@ public virtual string GetPartitionKey([NotNull] IReadOnlyDictionary - public virtual int AddToProjection([NotNull] ObjectArrayProjectionExpression objectArrayProjection) => - AddToProjection(objectArrayProjection, null); + public virtual int AddToProjection([NotNull] ObjectArrayProjectionExpression objectArrayProjection) + => AddToProjection(objectArrayProjection, null); private int AddToProjection([NotNull] Expression expression, string alias) { @@ -260,8 +260,8 @@ private int AddToProjection([NotNull] Expression expression, string alias) } var baseAlias = alias - ?? (expression as IAccessExpression)?.Name - ?? "c"; + ?? (expression as IAccessExpression)?.Name + ?? "c"; var currentAlias = baseAlias; var counter = 0; @@ -421,7 +421,8 @@ public virtual void ReverseOrderings() /// 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 override Type Type => typeof(object); + public override Type Type + => typeof(object); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -429,7 +430,8 @@ public virtual void ReverseOrderings() /// 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 sealed override ExpressionType NodeType => ExpressionType.Extension; + public sealed override ExpressionType NodeType + => ExpressionType.Extension; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Cosmos/Query/Internal/SqlBinaryExpression.cs b/src/EFCore.Cosmos/Query/Internal/SqlBinaryExpression.cs index 34e9f16c7bb..911d127a788 100644 --- a/src/EFCore.Cosmos/Query/Internal/SqlBinaryExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/SqlBinaryExpression.cs @@ -6,7 +6,6 @@ using System.Linq.Expressions; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Cosmos.Internal; -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Storage; @@ -47,8 +46,9 @@ public class SqlBinaryExpression : SqlExpression private static ExpressionType VerifyOperator(ExpressionType operatorType) => _allowedOperators.Contains(operatorType) ? operatorType - : throw new InvalidOperationException(CosmosStrings.UnsupportedOperatorForSqlExpression( - operatorType, typeof(SqlBinaryExpression).ShortDisplayName())); + : throw new InvalidOperationException( + CosmosStrings.UnsupportedOperatorForSqlExpression( + operatorType, typeof(SqlBinaryExpression).ShortDisplayName())); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -164,7 +164,8 @@ protected override void Print(ExpressionPrinter expressionPrinter) expressionPrinter.Append(")"); } - static bool RequiresBrackets(SqlExpression expression) => expression is SqlBinaryExpression; + static bool RequiresBrackets(SqlExpression expression) + => expression is SqlBinaryExpression; } /// @@ -175,15 +176,15 @@ protected override void Print(ExpressionPrinter expressionPrinter) /// public override bool Equals(object obj) => obj != null - && (ReferenceEquals(this, obj) - || obj is SqlBinaryExpression sqlBinaryExpression - && Equals(sqlBinaryExpression)); + && (ReferenceEquals(this, obj) + || obj is SqlBinaryExpression sqlBinaryExpression + && Equals(sqlBinaryExpression)); private bool Equals(SqlBinaryExpression sqlBinaryExpression) => base.Equals(sqlBinaryExpression) - && OperatorType == sqlBinaryExpression.OperatorType - && Left.Equals(sqlBinaryExpression.Left) - && Right.Equals(sqlBinaryExpression.Right); + && OperatorType == sqlBinaryExpression.OperatorType + && Left.Equals(sqlBinaryExpression.Left) + && Right.Equals(sqlBinaryExpression.Right); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -191,6 +192,7 @@ private bool Equals(SqlBinaryExpression sqlBinaryExpression) /// 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 override int GetHashCode() => HashCode.Combine(base.GetHashCode(), OperatorType, Left, Right); + public override int GetHashCode() + => HashCode.Combine(base.GetHashCode(), OperatorType, Left, Right); } } diff --git a/src/EFCore.Cosmos/Query/Internal/SqlConditionalExpression.cs b/src/EFCore.Cosmos/Query/Internal/SqlConditionalExpression.cs index 344e152a7a3..02d190afb65 100644 --- a/src/EFCore.Cosmos/Query/Internal/SqlConditionalExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/SqlConditionalExpression.cs @@ -116,15 +116,15 @@ protected override void Print(ExpressionPrinter expressionPrinter) /// public override bool Equals(object obj) => obj != null - && (ReferenceEquals(this, obj) - || obj is SqlConditionalExpression sqlConditionalExpression - && Equals(sqlConditionalExpression)); + && (ReferenceEquals(this, obj) + || obj is SqlConditionalExpression sqlConditionalExpression + && Equals(sqlConditionalExpression)); private bool Equals(SqlConditionalExpression sqlConditionalExpression) => base.Equals(sqlConditionalExpression) - && Test.Equals(sqlConditionalExpression.Test) - && IfTrue.Equals(sqlConditionalExpression.IfTrue) - && IfFalse.Equals(sqlConditionalExpression.IfFalse); + && Test.Equals(sqlConditionalExpression.Test) + && IfTrue.Equals(sqlConditionalExpression.IfTrue) + && IfFalse.Equals(sqlConditionalExpression.IfFalse); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Cosmos/Query/Internal/SqlConstantExpression.cs b/src/EFCore.Cosmos/Query/Internal/SqlConstantExpression.cs index 677104f2627..42a6a5f3ce7 100644 --- a/src/EFCore.Cosmos/Query/Internal/SqlConstantExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/SqlConstantExpression.cs @@ -42,7 +42,8 @@ public SqlConstantExpression([NotNull] ConstantExpression constantExpression, [N /// 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 virtual object Value => _constantExpression.Value; + public virtual object Value + => _constantExpression.Value; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -138,15 +139,15 @@ private JToken GenerateJToken(object value, CoreTypeMapping typeMapping) /// public override bool Equals(object obj) => obj != null - && (ReferenceEquals(this, obj) - || obj is SqlConstantExpression sqlConstantExpression - && Equals(sqlConstantExpression)); + && (ReferenceEquals(this, obj) + || obj is SqlConstantExpression sqlConstantExpression + && Equals(sqlConstantExpression)); private bool Equals(SqlConstantExpression sqlConstantExpression) => base.Equals(sqlConstantExpression) - && (Value == null - ? sqlConstantExpression.Value == null - : Value.Equals(sqlConstantExpression.Value)); + && (Value == null + ? sqlConstantExpression.Value == null + : Value.Equals(sqlConstantExpression.Value)); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -154,6 +155,7 @@ private bool Equals(SqlConstantExpression sqlConstantExpression) /// 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 override int GetHashCode() => HashCode.Combine(base.GetHashCode(), Value); + public override int GetHashCode() + => HashCode.Combine(base.GetHashCode(), Value); } } diff --git a/src/EFCore.Cosmos/Query/Internal/SqlExpression.cs b/src/EFCore.Cosmos/Query/Internal/SqlExpression.cs index dd5da5b8c72..86a90b72259 100644 --- a/src/EFCore.Cosmos/Query/Internal/SqlExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/SqlExpression.cs @@ -5,7 +5,6 @@ using System.Linq.Expressions; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Cosmos.Internal; -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Storage; @@ -62,7 +61,8 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// 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 sealed override ExpressionType NodeType => ExpressionType.Extension; + public sealed override ExpressionType NodeType + => ExpressionType.Extension; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -73,7 +73,8 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) protected abstract void Print([NotNull] ExpressionPrinter expressionPrinter); /// - void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) => Print(expressionPrinter); + void IPrintableExpression.Print(ExpressionPrinter expressionPrinter) + => Print(expressionPrinter); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -83,13 +84,13 @@ protected override Expression VisitChildren(ExpressionVisitor visitor) /// public override bool Equals(object obj) => obj != null - && (ReferenceEquals(this, obj) - || obj is SqlExpression sqlExpression - && Equals(sqlExpression)); + && (ReferenceEquals(this, obj) + || obj is SqlExpression sqlExpression + && Equals(sqlExpression)); private bool Equals(SqlExpression sqlExpression) => Type == sqlExpression.Type - && TypeMapping?.Equals(sqlExpression.TypeMapping) == true; + && TypeMapping?.Equals(sqlExpression.TypeMapping) == true; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -97,6 +98,7 @@ private bool Equals(SqlExpression sqlExpression) /// 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 override int GetHashCode() => HashCode.Combine(Type, TypeMapping); + public override int GetHashCode() + => HashCode.Combine(Type, TypeMapping); } } diff --git a/src/EFCore.Cosmos/Query/Internal/SqlExpressionFactory.cs b/src/EFCore.Cosmos/Query/Internal/SqlExpressionFactory.cs index d8b291430af..e565a2f3855 100644 --- a/src/EFCore.Cosmos/Query/Internal/SqlExpressionFactory.cs +++ b/src/EFCore.Cosmos/Query/Internal/SqlExpressionFactory.cs @@ -7,7 +7,6 @@ using System.Linq.Expressions; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Cosmos.Internal; -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Metadata; @@ -49,8 +48,8 @@ public virtual SqlExpression ApplyDefaultTypeMapping(SqlExpression sqlExpression { return sqlExpression == null || sqlExpression.TypeMapping != null - ? sqlExpression - : ApplyTypeMapping(sqlExpression, _typeMappingSource.FindMapping(sqlExpression.Type)); + ? sqlExpression + : ApplyTypeMapping(sqlExpression, _typeMappingSource.FindMapping(sqlExpression.Type)); } /// @@ -95,7 +94,8 @@ public virtual SqlExpression ApplyTypeMapping(SqlExpression sqlExpression, CoreT } private SqlExpression ApplyTypeMappingOnSqlConditional( - SqlConditionalExpression sqlConditionalExpression, CoreTypeMapping typeMapping) + SqlConditionalExpression sqlConditionalExpression, + CoreTypeMapping typeMapping) { return sqlConditionalExpression.Update( sqlConditionalExpression.Test, @@ -104,7 +104,8 @@ private SqlExpression ApplyTypeMappingOnSqlConditional( } private SqlExpression ApplyTypeMappingOnSqlUnary( - SqlUnaryExpression sqlUnaryExpression, CoreTypeMapping typeMapping) + SqlUnaryExpression sqlUnaryExpression, + CoreTypeMapping typeMapping) { SqlExpression operand; Type resultType; @@ -138,15 +139,18 @@ when sqlUnaryExpression.IsLogicalNot(): break; default: - throw new InvalidOperationException(CosmosStrings.UnsupportedOperatorForSqlExpression( - sqlUnaryExpression.OperatorType, typeof(SqlUnaryExpression).ShortDisplayName()));; + throw new InvalidOperationException( + CosmosStrings.UnsupportedOperatorForSqlExpression( + sqlUnaryExpression.OperatorType, typeof(SqlUnaryExpression).ShortDisplayName())); + ; } return new SqlUnaryExpression(sqlUnaryExpression.OperatorType, operand, resultType, resultTypeMapping); } private SqlExpression ApplyTypeMappingOnSqlBinary( - SqlBinaryExpression sqlBinaryExpression, CoreTypeMapping typeMapping) + SqlBinaryExpression sqlBinaryExpression, + CoreTypeMapping typeMapping) { var left = sqlBinaryExpression.Left; var right = sqlBinaryExpression.Right; @@ -171,7 +175,7 @@ private SqlExpression ApplyTypeMappingOnSqlBinary( resultType = typeof(bool); resultTypeMapping = _boolTypeMapping; } - break; + break; case ExpressionType.AndAlso: case ExpressionType.OrElse: @@ -180,7 +184,7 @@ private SqlExpression ApplyTypeMappingOnSqlBinary( resultType = typeof(bool); resultTypeMapping = _boolTypeMapping; } - break; + break; case ExpressionType.Add: case ExpressionType.Subtract: @@ -196,11 +200,12 @@ private SqlExpression ApplyTypeMappingOnSqlBinary( resultType = inferredTypeMapping?.ClrType ?? left.Type; resultTypeMapping = inferredTypeMapping; } - break; + break; default: - throw new InvalidOperationException(CosmosStrings.UnsupportedOperatorForSqlExpression( - sqlBinaryExpression.OperatorType, typeof(SqlBinaryExpression).ShortDisplayName())); + throw new InvalidOperationException( + CosmosStrings.UnsupportedOperatorForSqlExpression( + sqlBinaryExpression.OperatorType, typeof(SqlBinaryExpression).ShortDisplayName())); } return new SqlBinaryExpression( @@ -227,7 +232,10 @@ public virtual CoreTypeMapping FindMapping(Type type) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlBinaryExpression MakeBinary( - ExpressionType operatorType, SqlExpression left, SqlExpression right, CoreTypeMapping typeMapping) + ExpressionType operatorType, + SqlExpression left, + SqlExpression right, + CoreTypeMapping typeMapping) { var returnType = left.Type; switch (operatorType) @@ -384,7 +392,10 @@ public virtual SqlBinaryExpression Or(SqlExpression left, SqlExpression right, C => MakeBinary(ExpressionType.Or, left, right, typeMapping); private SqlUnaryExpression MakeUnary( - ExpressionType operatorType, SqlExpression operand, Type type, CoreTypeMapping typeMapping = null) + ExpressionType operatorType, + SqlExpression operand, + Type type, + CoreTypeMapping typeMapping = null) { return (SqlUnaryExpression)ApplyTypeMapping(new SqlUnaryExpression(operatorType, operand, type, null), typeMapping); } @@ -441,7 +452,10 @@ public virtual SqlUnaryExpression Negate(SqlExpression operand) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlFunctionExpression Function( - string functionName, IEnumerable arguments, Type returnType, CoreTypeMapping typeMapping = null) + string functionName, + IEnumerable arguments, + Type returnType, + CoreTypeMapping typeMapping = null) { var typeMappedArguments = new List(); diff --git a/src/EFCore.Cosmos/Query/Internal/SqlFunctionExpression.cs b/src/EFCore.Cosmos/Query/Internal/SqlFunctionExpression.cs index 6568006231f..7510757fe05 100644 --- a/src/EFCore.Cosmos/Query/Internal/SqlFunctionExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/SqlFunctionExpression.cs @@ -128,14 +128,14 @@ protected override void Print(ExpressionPrinter expressionPrinter) /// public override bool Equals(object obj) => obj != null - && (ReferenceEquals(this, obj) - || obj is SqlFunctionExpression sqlFunctionExpression - && Equals(sqlFunctionExpression)); + && (ReferenceEquals(this, obj) + || obj is SqlFunctionExpression sqlFunctionExpression + && Equals(sqlFunctionExpression)); private bool Equals(SqlFunctionExpression sqlFunctionExpression) => base.Equals(sqlFunctionExpression) - && string.Equals(Name, sqlFunctionExpression.Name) - && Arguments.SequenceEqual(sqlFunctionExpression.Arguments); + && string.Equals(Name, sqlFunctionExpression.Name) + && Arguments.SequenceEqual(sqlFunctionExpression.Arguments); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Cosmos/Query/Internal/SqlParameterExpression.cs b/src/EFCore.Cosmos/Query/Internal/SqlParameterExpression.cs index b92b6bbedf3..3dde9f42b70 100644 --- a/src/EFCore.Cosmos/Query/Internal/SqlParameterExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/SqlParameterExpression.cs @@ -38,7 +38,8 @@ public SqlParameterExpression([NotNull] ParameterExpression parameterExpression, /// 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 string Name => _parameterExpression.Name; + public string Name + => _parameterExpression.Name; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -97,6 +98,7 @@ private bool Equals(SqlParameterExpression sqlParameterExpression) /// 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 override int GetHashCode() => HashCode.Combine(base.GetHashCode(), Name); + public override int GetHashCode() + => HashCode.Combine(base.GetHashCode(), Name); } } diff --git a/src/EFCore.Cosmos/Query/Internal/SqlUnaryExpression.cs b/src/EFCore.Cosmos/Query/Internal/SqlUnaryExpression.cs index 86ceb83c5ad..d7dae6a93f6 100644 --- a/src/EFCore.Cosmos/Query/Internal/SqlUnaryExpression.cs +++ b/src/EFCore.Cosmos/Query/Internal/SqlUnaryExpression.cs @@ -6,7 +6,6 @@ using System.Linq.Expressions; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Cosmos.Internal; -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Storage; @@ -24,14 +23,17 @@ public class SqlUnaryExpression : SqlExpression { private static readonly ISet _allowedOperators = new HashSet { - ExpressionType.Not, ExpressionType.Negate, ExpressionType.UnaryPlus + ExpressionType.Not, + ExpressionType.Negate, + ExpressionType.UnaryPlus }; private static ExpressionType VerifyOperator(ExpressionType operatorType) => _allowedOperators.Contains(operatorType) ? operatorType - : throw new InvalidOperationException(CosmosStrings.UnsupportedOperatorForSqlExpression( - operatorType, typeof(SqlUnaryExpression).ShortDisplayName())); + : throw new InvalidOperationException( + CosmosStrings.UnsupportedOperatorForSqlExpression( + operatorType, typeof(SqlUnaryExpression).ShortDisplayName())); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -115,14 +117,14 @@ protected override void Print(ExpressionPrinter expressionPrinter) /// public override bool Equals(object obj) => obj != null - && (ReferenceEquals(this, obj) - || obj is SqlUnaryExpression sqlUnaryExpression - && Equals(sqlUnaryExpression)); + && (ReferenceEquals(this, obj) + || obj is SqlUnaryExpression sqlUnaryExpression + && Equals(sqlUnaryExpression)); private bool Equals(SqlUnaryExpression sqlUnaryExpression) => base.Equals(sqlUnaryExpression) - && OperatorType == sqlUnaryExpression.OperatorType - && Operand.Equals(sqlUnaryExpression.Operand); + && OperatorType == sqlUnaryExpression.OperatorType + && Operand.Equals(sqlUnaryExpression.Operand); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -130,6 +132,7 @@ private bool Equals(SqlUnaryExpression sqlUnaryExpression) /// 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 override int GetHashCode() => HashCode.Combine(base.GetHashCode(), OperatorType, Operand); + public override int GetHashCode() + => HashCode.Combine(base.GetHashCode(), OperatorType, Operand); } } diff --git a/src/EFCore.Cosmos/Query/Internal/StringMethodTranslator.cs b/src/EFCore.Cosmos/Query/Internal/StringMethodTranslator.cs index 99e30a84739..85c707090d5 100644 --- a/src/EFCore.Cosmos/Query/Internal/StringMethodTranslator.cs +++ b/src/EFCore.Cosmos/Query/Internal/StringMethodTranslator.cs @@ -29,14 +29,14 @@ private static readonly MethodInfo _endsWithMethodInfo = typeof(string).GetRuntimeMethod(nameof(string.EndsWith), new[] { typeof(string) }); private static readonly MethodInfo _firstOrDefaultMethodInfoWithoutArgs - = typeof(Enumerable).GetRuntimeMethods().Single( - m => m.Name == nameof(Enumerable.FirstOrDefault) - && m.GetParameters().Length == 1).MakeGenericMethod(new[] { typeof(char) }); + = typeof(Enumerable).GetRuntimeMethods().Single( + m => m.Name == nameof(Enumerable.FirstOrDefault) + && m.GetParameters().Length == 1).MakeGenericMethod(typeof(char)); private static readonly MethodInfo _lastOrDefaultMethodInfoWithoutArgs - = typeof(Enumerable).GetRuntimeMethods().Single( + = typeof(Enumerable).GetRuntimeMethods().Single( m => m.Name == nameof(Enumerable.LastOrDefault) - && m.GetParameters().Length == 1).MakeGenericMethod(new[] { typeof(char) }); + && m.GetParameters().Length == 1).MakeGenericMethod(typeof(char)); private readonly ISqlExpressionFactory _sqlExpressionFactory; @@ -58,7 +58,10 @@ public StringMethodTranslator([NotNull] ISqlExpressionFactory sqlExpressionFacto /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) + SqlExpression instance, + MethodInfo method, + IReadOnlyList arguments, + IDiagnosticsLogger logger) { Check.NotNull(method, nameof(method)); Check.NotNull(arguments, nameof(arguments)); @@ -74,7 +77,6 @@ public virtual SqlExpression Translate( return TranslateSystemFunction("LEFT", arguments[0], _sqlExpressionFactory.Constant(1), typeof(char)); } - if (_lastOrDefaultMethodInfoWithoutArgs.Equals(method)) { return TranslateSystemFunction("RIGHT", arguments[0], _sqlExpressionFactory.Constant(1), typeof(char)); diff --git a/src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs b/src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs index 72de1c6bf3e..198768949a1 100644 --- a/src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs +++ b/src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs @@ -92,7 +92,8 @@ public CosmosClientWrapper( _commandLogger = commandLogger; } - private CosmosClient Client => _singletonWrapper.Client; + private CosmosClient Client + => _singletonWrapper.Client; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -582,7 +583,8 @@ private IAsyncEnumerable CreateQuery( var queryDefinition = new QueryDefinition(query.Query); queryDefinition = query.Parameters - .Aggregate(queryDefinition, + .Aggregate( + queryDefinition, (current, parameter) => current.WithParameter(parameter.Name, parameter.Value)); if (string.IsNullOrEmpty(partitionKey)) @@ -610,7 +612,6 @@ private async Task CreateSingleItemQuery( .ConfigureAwait(false); } - [MethodImpl(MethodImplOptions.AggressiveInlining)] private static JsonTextReader CreateJsonReader(TextReader reader) { @@ -678,9 +679,11 @@ public DocumentEnumerable( _cosmosSqlQuery = cosmosSqlQuery; } - public IEnumerator GetEnumerator() => new Enumerator(this); + public IEnumerator GetEnumerator() + => new Enumerator(this); - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() + => GetEnumerator(); private sealed class Enumerator : IEnumerator { @@ -703,9 +706,11 @@ public Enumerator(DocumentEnumerable documentEnumerable) _partitionKey = documentEnumerable._partitionKey; _cosmosSqlQuery = documentEnumerable._cosmosSqlQuery; } + public JObject Current { get; private set; } - object IEnumerator.Current => Current; + object IEnumerator.Current + => Current; [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool MoveNext() @@ -713,7 +718,7 @@ public bool MoveNext() if (_jsonReader == null) { _query ??= _cosmosClientWrapper.CreateQuery(_containerId, _partitionKey, _cosmosSqlQuery).GetAsyncEnumerator(); - + if (!_query.MoveNextAsync().AsTask().GetAwaiter().GetResult()) { Current = default; @@ -757,7 +762,8 @@ public void Dispose() _response = null; } - public void Reset() => throw new NotImplementedException(); + public void Reset() + => throw new NotImplementedException(); } } @@ -816,7 +822,8 @@ public async ValueTask MoveNextAsync() if (_jsonReader == null) { - _query ??= _cosmosClientWrapper.CreateQuery(_containerId, _partitionKey, _cosmosSqlQuery).GetAsyncEnumerator(_cancellationToken); + _query ??= _cosmosClientWrapper.CreateQuery(_containerId, _partitionKey, _cosmosSqlQuery) + .GetAsyncEnumerator(_cancellationToken); if (!await _query.MoveNextAsync().ConfigureAwait(false)) { diff --git a/src/EFCore.Cosmos/Storage/Internal/CosmosConcurrencyMode.cs b/src/EFCore.Cosmos/Storage/Internal/CosmosConcurrencyMode.cs index 7a01a4916a0..c69cc7dc06e 100644 --- a/src/EFCore.Cosmos/Storage/Internal/CosmosConcurrencyMode.cs +++ b/src/EFCore.Cosmos/Storage/Internal/CosmosConcurrencyMode.cs @@ -12,17 +12,17 @@ namespace Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal public enum CosmosConcurrencyMode { /// - /// No concurrency check. + /// No concurrency check. /// None = 0, /// - /// Accept if token matches current value. + /// Accept if token matches current value. /// IfMatch, /// - /// Accept if token does not match current value. + /// Accept if token does not match current value. /// IfNoneMatch = 2, } diff --git a/src/EFCore.Cosmos/Storage/Internal/CosmosDatabaseCreator.cs b/src/EFCore.Cosmos/Storage/Internal/CosmosDatabaseCreator.cs index 3cf2d0685a3..3d4740318cb 100644 --- a/src/EFCore.Cosmos/Storage/Internal/CosmosDatabaseCreator.cs +++ b/src/EFCore.Cosmos/Storage/Internal/CosmosDatabaseCreator.cs @@ -148,7 +148,8 @@ private IUpdateAdapter AddSeedData() /// 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 virtual bool EnsureDeleted() => _cosmosClient.DeleteDatabase(); + public virtual bool EnsureDeleted() + => _cosmosClient.DeleteDatabase(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Cosmos/Storage/Internal/CosmosDatabaseWrapper.cs b/src/EFCore.Cosmos/Storage/Internal/CosmosDatabaseWrapper.cs index e9e85f4dc5f..1f47920376e 100644 --- a/src/EFCore.Cosmos/Storage/Internal/CosmosDatabaseWrapper.cs +++ b/src/EFCore.Cosmos/Storage/Internal/CosmosDatabaseWrapper.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Net; +using System.Runtime.ExceptionServices; using System.Threading; using System.Threading.Tasks; using Azure.Cosmos; @@ -20,8 +21,6 @@ using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json.Linq; -using Database = Microsoft.EntityFrameworkCore.Storage.Database; - namespace Microsoft.EntityFrameworkCore.Cosmos.Storage.Internal { /// @@ -143,7 +142,8 @@ public override int SaveChanges(IList entries) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public override async Task SaveChangesAsync( - IList entries, CancellationToken cancellationToken = default) + IList entries, + CancellationToken cancellationToken = default) { var rowsAffected = 0; var entriesSaved = new HashSet(); @@ -395,9 +395,9 @@ private Exception ThrowUpdateException(CosmosException exception, IUpdateEntry e throw exception.Status switch { (int)HttpStatusCode.PreconditionFailed => - new DbUpdateConcurrencyException(CosmosStrings.UpdateConflict(id), exception, new[] { entry }), + new DbUpdateConcurrencyException(CosmosStrings.UpdateConflict(id), exception, new[] { entry }), (int)HttpStatusCode.Conflict => - new DbUpdateException(CosmosStrings.UpdateConflict(id), exception, new[] { entry }), + new DbUpdateException(CosmosStrings.UpdateConflict(id), exception, new[] { entry }), _ => Rethrow(exception), }; } @@ -409,9 +409,9 @@ private Exception ThrowUpdateException(HttpException exception, IUpdateEntry ent throw exception.Response.Status switch { (int)HttpStatusCode.PreconditionFailed => - new DbUpdateConcurrencyException(CosmosStrings.UpdateConflict(id), exception, new[] { entry }), + new DbUpdateConcurrencyException(CosmosStrings.UpdateConflict(id), exception, new[] { entry }), (int)HttpStatusCode.Conflict => - new DbUpdateException(CosmosStrings.UpdateConflict(id), exception, new[] { entry }), + new DbUpdateException(CosmosStrings.UpdateConflict(id), exception, new[] { entry }), _ => Rethrow(exception), }; } @@ -419,7 +419,7 @@ private Exception ThrowUpdateException(HttpException exception, IUpdateEntry ent private static Exception Rethrow(Exception ex) { // Re-throw an exception, preserving the original stack and details, without being in the original "catch" block. - System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture(ex).Throw(); + ExceptionDispatchInfo.Capture(ex).Throw(); return ex; } } diff --git a/src/EFCore.Cosmos/Storage/Internal/CosmosExecutionStrategy.cs b/src/EFCore.Cosmos/Storage/Internal/CosmosExecutionStrategy.cs index ac58c510e2d..c8d19ca68d4 100644 --- a/src/EFCore.Cosmos/Storage/Internal/CosmosExecutionStrategy.cs +++ b/src/EFCore.Cosmos/Storage/Internal/CosmosExecutionStrategy.cs @@ -118,7 +118,7 @@ protected override bool ShouldRetryOn(Exception exception) static bool IsTransient(int status) => status == (int)HttpStatusCode.ServiceUnavailable - || status == (int)HttpStatusCode.TooManyRequests; + || status == (int)HttpStatusCode.TooManyRequests; } /// @@ -133,7 +133,7 @@ static bool IsTransient(int status) return baseDelay == null ? null : CallOnWrappedException(lastException, GetDelayFromException) - ?? baseDelay; + ?? baseDelay; } private static TimeSpan? GetDelayFromException(Exception exception) diff --git a/src/EFCore.Cosmos/Storage/Internal/CosmosExecutionStrategyFactory.cs b/src/EFCore.Cosmos/Storage/Internal/CosmosExecutionStrategyFactory.cs index 1447372a48a..b8f6dd6da78 100644 --- a/src/EFCore.Cosmos/Storage/Internal/CosmosExecutionStrategyFactory.cs +++ b/src/EFCore.Cosmos/Storage/Internal/CosmosExecutionStrategyFactory.cs @@ -41,7 +41,7 @@ public CosmosExecutionStrategyFactory([NotNull] ExecutionStrategyDependencies de Dependencies = dependencies; _createExecutionStrategy = dependencies.Options?.FindExtension()?.ExecutionStrategyFactory - ?? CreateDefaultStrategy; + ?? CreateDefaultStrategy; } /// @@ -67,6 +67,7 @@ protected virtual IExecutionStrategy CreateDefaultStrategy([NotNull] ExecutionSt /// 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 virtual IExecutionStrategy Create() => _createExecutionStrategy(Dependencies); + public virtual IExecutionStrategy Create() + => _createExecutionStrategy(Dependencies); } } diff --git a/src/EFCore.Cosmos/Storage/Internal/CosmosTransactionManager.cs b/src/EFCore.Cosmos/Storage/Internal/CosmosTransactionManager.cs index 79784f94a5c..d6162c56156 100644 --- a/src/EFCore.Cosmos/Storage/Internal/CosmosTransactionManager.cs +++ b/src/EFCore.Cosmos/Storage/Internal/CosmosTransactionManager.cs @@ -23,7 +23,8 @@ public class CosmosTransactionManager : IDbContextTransactionManager, ITransacti /// 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 virtual IDbContextTransaction BeginTransaction() => throw new NotSupportedException(); + public virtual IDbContextTransaction BeginTransaction() + => throw new NotSupportedException(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -41,7 +42,8 @@ public virtual Task BeginTransactionAsync( /// 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 virtual void CommitTransaction() => throw new NotSupportedException(); + public virtual void CommitTransaction() + => throw new NotSupportedException(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -58,7 +60,8 @@ public virtual Task CommitTransactionAsync(CancellationToken cancellationToken = /// 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 virtual void RollbackTransaction() => throw new NotSupportedException(); + public virtual void RollbackTransaction() + => throw new NotSupportedException(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -75,7 +78,8 @@ public virtual Task RollbackTransactionAsync(CancellationToken cancellationToken /// 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 virtual IDbContextTransaction CurrentTransaction => null; + public virtual IDbContextTransaction CurrentTransaction + => null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -83,7 +87,8 @@ public virtual Task RollbackTransactionAsync(CancellationToken cancellationToken /// 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 virtual Transaction EnlistedTransaction => null; + public virtual Transaction EnlistedTransaction + => null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -91,7 +96,8 @@ public virtual Task RollbackTransactionAsync(CancellationToken cancellationToken /// 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 virtual void EnlistTransaction(Transaction transaction) => throw new NotSupportedException(); + public virtual void EnlistTransaction(Transaction transaction) + => throw new NotSupportedException(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Cosmos/Storage/Internal/CosmosTypeMappingSource.cs b/src/EFCore.Cosmos/Storage/Internal/CosmosTypeMappingSource.cs index 07fa2bada71..373b9e748f5 100644 --- a/src/EFCore.Cosmos/Storage/Internal/CosmosTypeMappingSource.cs +++ b/src/EFCore.Cosmos/Storage/Internal/CosmosTypeMappingSource.cs @@ -3,13 +3,9 @@ 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; @@ -59,7 +55,7 @@ protected override CoreTypeMapping FindMapping(in TypeMappingInfo mappingInfo) } if ((clrType.IsValueType - && !clrType.IsEnum) + && !clrType.IsEnum) || clrType == typeof(string)) { return new CosmosTypeMapping(clrType); diff --git a/src/EFCore.Cosmos/Storage/Internal/JsonCosmosSerializer.cs b/src/EFCore.Cosmos/Storage/Internal/JsonCosmosSerializer.cs index 984e594da29..582ee0cfa33 100644 --- a/src/EFCore.Cosmos/Storage/Internal/JsonCosmosSerializer.cs +++ b/src/EFCore.Cosmos/Storage/Internal/JsonCosmosSerializer.cs @@ -51,6 +51,7 @@ public override Stream ToStream(T input) return streamPayload; } - private JsonSerializer GetSerializer() => CosmosClientWrapper.Serializer; + private JsonSerializer GetSerializer() + => CosmosClientWrapper.Serializer; } } diff --git a/src/EFCore.Cosmos/Storage/Internal/SingletonCosmosClientWrapper.cs b/src/EFCore.Cosmos/Storage/Internal/SingletonCosmosClientWrapper.cs index 9a7a7689cb0..800d4fd0a18 100644 --- a/src/EFCore.Cosmos/Storage/Internal/SingletonCosmosClientWrapper.cs +++ b/src/EFCore.Cosmos/Storage/Internal/SingletonCosmosClientWrapper.cs @@ -44,11 +44,7 @@ public SingletonCosmosClientWrapper([NotNull] ICosmosSingletonOptions options) _endpoint = options.AccountEndpoint; _key = options.AccountKey; _connectionString = options.ConnectionString; - var configuration = new CosmosClientOptions - { - ApplicationName = _userAgent, - Serializer = new JsonCosmosSerializer() - }; + var configuration = new CosmosClientOptions { ApplicationName = _userAgent, Serializer = new JsonCosmosSerializer() }; if (options.Region != null) { @@ -109,9 +105,10 @@ public SingletonCosmosClientWrapper([NotNull] ICosmosSingletonOptions options) /// 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 virtual CosmosClient Client => _client ??= string.IsNullOrEmpty(_connectionString) - ? new CosmosClient(_endpoint, _key, _options) - : new CosmosClient(_connectionString, _options); + public virtual CosmosClient Client + => _client ??= string.IsNullOrEmpty(_connectionString) + ? new CosmosClient(_endpoint, _key, _options) + : new CosmosClient(_connectionString, _options); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Cosmos/Update/Internal/DocumentSource.cs b/src/EFCore.Cosmos/Update/Internal/DocumentSource.cs index dc67059e76c..8bbc830ea0f 100644 --- a/src/EFCore.Cosmos/Update/Internal/DocumentSource.cs +++ b/src/EFCore.Cosmos/Update/Internal/DocumentSource.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; using System.Collections; using System.Linq; using JetBrains.Annotations; @@ -305,8 +304,9 @@ public virtual JObject UpdateDocument([NotNull] JObject document, [NotNull] IUpd } private IProperty GetOrdinalKeyProperty(IEntityType entityType) - => entityType.FindPrimaryKey().Properties.FirstOrDefault(p => - p.GetJsonPropertyName().Length == 0 && p.IsOrdinalKeyProperty()); + => entityType.FindPrimaryKey().Properties.FirstOrDefault( + p => + p.GetJsonPropertyName().Length == 0 && p.IsOrdinalKeyProperty()); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Cosmos/ValueGeneration/Internal/IdValueGenerator.cs b/src/EFCore.Cosmos/ValueGeneration/Internal/IdValueGenerator.cs index 949c25512da..deec6e19c2a 100644 --- a/src/EFCore.Cosmos/ValueGeneration/Internal/IdValueGenerator.cs +++ b/src/EFCore.Cosmos/ValueGeneration/Internal/IdValueGenerator.cs @@ -23,7 +23,8 @@ public class IdValueGenerator : ValueGenerator /// 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 override bool GeneratesTemporaryValues => false; + public override bool GeneratesTemporaryValues + => false; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.InMemory/Diagnostics/InMemoryEventId.cs b/src/EFCore.InMemory/Diagnostics/InMemoryEventId.cs index f61d82d2bfc..376e0d32704 100644 --- a/src/EFCore.InMemory/Diagnostics/InMemoryEventId.cs +++ b/src/EFCore.InMemory/Diagnostics/InMemoryEventId.cs @@ -31,7 +31,9 @@ private enum Id } private static readonly string _transactionPrefix = DbLoggerCategory.Database.Transaction.Name + "."; - private static EventId MakeTransactionId(Id id) => new EventId((int)id, _transactionPrefix + id); + + private static EventId MakeTransactionId(Id id) + => new EventId((int)id, _transactionPrefix + id); /// /// @@ -47,7 +49,9 @@ private enum Id public static readonly EventId TransactionIgnoredWarning = MakeTransactionId(Id.TransactionIgnoredWarning); private static readonly string _updatePrefix = DbLoggerCategory.Update.Name + "."; - private static EventId MakeUpdateId(Id id) => new EventId((int)id, _updatePrefix + id); + + private static EventId MakeUpdateId(Id id) + => new EventId((int)id, _updatePrefix + id); /// /// diff --git a/src/EFCore.InMemory/Infrastructure/InMemoryDbContextOptionsBuilder.cs b/src/EFCore.InMemory/Infrastructure/InMemoryDbContextOptionsBuilder.cs index 7f44af43fb1..43e931a9650 100644 --- a/src/EFCore.InMemory/Infrastructure/InMemoryDbContextOptionsBuilder.cs +++ b/src/EFCore.InMemory/Infrastructure/InMemoryDbContextOptionsBuilder.cs @@ -44,22 +44,25 @@ public InMemoryDbContextOptionsBuilder([NotNull] DbContextOptionsBuilder options /// /// A string that represents the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override string ToString() => base.ToString(); + public override string ToString() + => base.ToString(); /// /// Determines whether the specified object is equal to the current object. /// /// The object to compare with the current object. - /// if the specified object is equal to the current object; otherwise, . + /// if the specified object is equal to the current object; otherwise, . [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => base.Equals(obj); + public override bool Equals(object obj) + => base.Equals(obj); /// /// Serves as the default hash function. /// /// A hash code for the current object. [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => base.GetHashCode(); + public override int GetHashCode() + => base.GetHashCode(); #endregion } diff --git a/src/EFCore.InMemory/Infrastructure/Internal/InMemoryOptionsExtension.cs b/src/EFCore.InMemory/Infrastructure/Internal/InMemoryOptionsExtension.cs index eb1b2ec3575..aefcc26f1ae 100644 --- a/src/EFCore.InMemory/Infrastructure/Internal/InMemoryOptionsExtension.cs +++ b/src/EFCore.InMemory/Infrastructure/Internal/InMemoryOptionsExtension.cs @@ -60,7 +60,8 @@ public virtual DbContextOptionsExtensionInfo Info /// 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. /// - protected virtual InMemoryOptionsExtension Clone() => new InMemoryOptionsExtension(this); + protected virtual InMemoryOptionsExtension Clone() + => new InMemoryOptionsExtension(this); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -68,7 +69,8 @@ public virtual DbContextOptionsExtensionInfo Info /// 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 virtual string StoreName => _storeName; + public virtual string StoreName + => _storeName; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -91,7 +93,8 @@ public virtual InMemoryOptionsExtension WithStoreName([NotNull] string storeName /// 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 virtual InMemoryDatabaseRoot DatabaseRoot => _databaseRoot; + public virtual InMemoryDatabaseRoot DatabaseRoot + => _databaseRoot; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -139,7 +142,8 @@ public ExtensionInfo(IDbContextOptionsExtension extension) private new InMemoryOptionsExtension Extension => (InMemoryOptionsExtension)base.Extension; - public override bool IsDatabaseProvider => true; + public override bool IsDatabaseProvider + => true; public override string LogFragment { @@ -158,7 +162,8 @@ public override string LogFragment } } - public override long GetServiceProviderHashCode() => Extension._databaseRoot?.GetHashCode() ?? 0L; + public override long GetServiceProviderHashCode() + => Extension._databaseRoot?.GetHashCode() ?? 0L; public override void PopulateDebugInfo(IDictionary debugInfo) => debugInfo["InMemoryDatabase:DatabaseRoot"] diff --git a/src/EFCore.InMemory/Internal/InMemoryModelValidator.cs b/src/EFCore.InMemory/Internal/InMemoryModelValidator.cs index 0c319f941f0..6111fa529f7 100644 --- a/src/EFCore.InMemory/Internal/InMemoryModelValidator.cs +++ b/src/EFCore.InMemory/Internal/InMemoryModelValidator.cs @@ -48,7 +48,8 @@ public override void Validate(IModel model, IDiagnosticsLogger The model to validate. /// The logger to use. protected virtual void ValidateDefiningQuery( - [NotNull] IModel model, [NotNull] IDiagnosticsLogger logger) + [NotNull] IModel model, + [NotNull] IDiagnosticsLogger logger) { Check.NotNull(model, nameof(model)); diff --git a/src/EFCore.InMemory/Metadata/Conventions/DefiningQueryRewritingConvention.cs b/src/EFCore.InMemory/Metadata/Conventions/DefiningQueryRewritingConvention.cs index a7ed83a164b..9b8593008c8 100644 --- a/src/EFCore.InMemory/Metadata/Conventions/DefiningQueryRewritingConvention.cs +++ b/src/EFCore.InMemory/Metadata/Conventions/DefiningQueryRewritingConvention.cs @@ -10,7 +10,8 @@ namespace Microsoft.EntityFrameworkCore.Metadata.Conventions { /// - /// Convention that converts accesses of inside query filters and defining queries into . + /// Convention that converts accesses of inside query filters and defining queries into + /// . /// This makes them consistent with how DbSet accesses in the actual queries are represented, which allows for easier processing in the /// query pipeline. /// diff --git a/src/EFCore.InMemory/Query/Internal/AnonymousObject.cs b/src/EFCore.InMemory/Query/Internal/AnonymousObject.cs index f9255713d27..091fbae58b2 100644 --- a/src/EFCore.InMemory/Query/Internal/AnonymousObject.cs +++ b/src/EFCore.InMemory/Query/Internal/AnonymousObject.cs @@ -36,7 +36,8 @@ public static readonly ConstructorInfo AnonymousObjectCtor /// doing so can result in application failures when updating to a new Entity Framework Core release. /// [UsedImplicitly] - public AnonymousObject([NotNull] object[] values) => _values = values; + public AnonymousObject([NotNull] object[] values) + => _values = values; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -44,7 +45,8 @@ public static readonly ConstructorInfo AnonymousObjectCtor /// 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 bool operator ==(AnonymousObject x, AnonymousObject y) => x.Equals(y); + public static bool operator ==(AnonymousObject x, AnonymousObject y) + => x.Equals(y); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -52,7 +54,8 @@ public static readonly ConstructorInfo AnonymousObjectCtor /// 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 bool operator !=(AnonymousObject x, AnonymousObject y) => !x.Equals(y); + public static bool operator !=(AnonymousObject x, AnonymousObject y) + => !x.Equals(y); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.InMemory/Query/Internal/EntityProjectionExpression.cs b/src/EFCore.InMemory/Query/Internal/EntityProjectionExpression.cs index ec7dbd62f20..aac4e0f8d90 100644 --- a/src/EFCore.InMemory/Query/Internal/EntityProjectionExpression.cs +++ b/src/EFCore.InMemory/Query/Internal/EntityProjectionExpression.cs @@ -6,7 +6,6 @@ using System.Linq; using System.Linq.Expressions; using JetBrains.Annotations; -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.InMemory.Internal; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Query; @@ -34,7 +33,8 @@ private readonly IDictionary _navigationExp /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public EntityProjectionExpression( - [NotNull] IEntityType entityType, [NotNull] IDictionary readExpressionMap) + [NotNull] IEntityType entityType, + [NotNull] IDictionary readExpressionMap) { EntityType = entityType; _readExpressionMap = readExpressionMap; @@ -47,20 +47,24 @@ public EntityProjectionExpression( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual IEntityType EntityType { get; } + /// /// 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 override Type Type => EntityType.ClrType; + public override Type Type + => EntityType.ClrType; + /// /// 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 sealed override ExpressionType NodeType => ExpressionType.Extension; + public sealed override ExpressionType NodeType + => ExpressionType.Extension; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -72,8 +76,9 @@ public virtual EntityProjectionExpression UpdateEntityType([NotNull] IEntityType { if (!derivedType.GetAllBaseTypes().Contains(EntityType)) { - throw new InvalidOperationException(InMemoryStrings.InvalidDerivedTypeInEntityProjection( - derivedType.DisplayName(), EntityType.DisplayName())); + throw new InvalidOperationException( + InMemoryStrings.InvalidDerivedTypeInEntityProjection( + derivedType.DisplayName(), EntityType.DisplayName())); } var readExpressionMap = new Dictionary(); diff --git a/src/EFCore.InMemory/Query/Internal/InMemoryExpressionTranslatingExpressionVisitor.cs b/src/EFCore.InMemory/Query/Internal/InMemoryExpressionTranslatingExpressionVisitor.cs index f9b00124b50..bcee5961bf8 100644 --- a/src/EFCore.InMemory/Query/Internal/InMemoryExpressionTranslatingExpressionVisitor.cs +++ b/src/EFCore.InMemory/Query/Internal/InMemoryExpressionTranslatingExpressionVisitor.cs @@ -35,14 +35,19 @@ public class InMemoryExpressionTranslatingExpressionVisitor : ExpressionVisitor private static readonly MethodInfo _parameterValueExtractor = typeof(InMemoryExpressionTranslatingExpressionVisitor).GetTypeInfo().GetDeclaredMethod(nameof(ParameterValueExtractor)); + private static readonly MethodInfo _parameterListValueExtractor = typeof(InMemoryExpressionTranslatingExpressionVisitor).GetTypeInfo().GetDeclaredMethod(nameof(ParameterListValueExtractor)); + private static readonly MethodInfo _getParameterValueMethodInfo = typeof(InMemoryExpressionTranslatingExpressionVisitor).GetTypeInfo().GetDeclaredMethod(nameof(GetParameterValue)); + private static readonly MethodInfo _likeMethodInfo = typeof(DbFunctionsExtensions).GetRuntimeMethod( - nameof(DbFunctionsExtensions.Like), new[] { typeof(DbFunctions), typeof(string), typeof(string) }); + nameof(DbFunctionsExtensions.Like), new[] { typeof(DbFunctions), typeof(string), typeof(string) }); + private static readonly MethodInfo _likeMethodInfoWithEscape = typeof(DbFunctionsExtensions).GetRuntimeMethod( - nameof(DbFunctionsExtensions.Like), new[] { typeof(DbFunctions), typeof(string), typeof(string), typeof(string) }); + nameof(DbFunctionsExtensions.Like), new[] { typeof(DbFunctions), typeof(string), typeof(string), typeof(string) }); + private static readonly MethodInfo _inMemoryLikeMethodInfo = typeof(InMemoryExpressionTranslatingExpressionVisitor).GetTypeInfo().GetDeclaredMethod(nameof(InMemoryLike)); @@ -54,6 +59,7 @@ private static readonly char[] _regexSpecialChars private static readonly string _defaultEscapeRegexCharsPattern = BuildEscapeRegexCharsPattern(_regexSpecialChars); private static readonly TimeSpan _regexTimeout = TimeSpan.FromMilliseconds(value: 1000.0); + private static string BuildEscapeRegexCharsPattern(IEnumerable regexSpecialChars) => string.Join("|", regexSpecialChars.Select(c => @"\" + c)); @@ -157,7 +163,7 @@ protected override Expression VisitBinary(BinaryExpression binaryExpression) } if ((binaryExpression.NodeType == ExpressionType.Equal - || binaryExpression.NodeType == ExpressionType.NotEqual) + || binaryExpression.NodeType == ExpressionType.NotEqual) // Visited expression could be null, We need to pass MemberInitExpression && TryRewriteEntityEquality( binaryExpression.NodeType, newLeft ?? binaryExpression.Left, newRight ?? binaryExpression.Right, out var result)) @@ -264,7 +270,7 @@ protected override Expression VisitExtension(Expression extensionExpression) case ProjectionBindingExpression projectionBindingExpression: return projectionBindingExpression.ProjectionMember != null ? ((InMemoryQueryExpression)projectionBindingExpression.QueryExpression) - .GetMappedProjection(projectionBindingExpression.ProjectionMember) + .GetMappedProjection(projectionBindingExpression.ProjectionMember) : null; case InMemoryGroupByShaperExpression inMemoryGroupByShaperExpression: @@ -284,21 +290,26 @@ protected override Expression VisitExtension(Expression extensionExpression) /// 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. /// - protected override Expression VisitInvocation(InvocationExpression invocationExpression) => null; + protected override Expression VisitInvocation(InvocationExpression invocationExpression) + => null; + /// /// 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. /// - protected override Expression VisitLambda(Expression lambdaExpression) => null; + protected override Expression VisitLambda(Expression lambdaExpression) + => null; + /// /// 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. /// - protected override Expression VisitListInit(ListInitExpression listInitExpression) => null; + protected override Expression VisitListInit(ListInitExpression listInitExpression) + => null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -417,7 +428,8 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp result = expression == null ? null - : Expression.Call(EnumerableMethods.GetAverageWithoutSelector(expression.Type.TryGetSequenceType()), expression); + : Expression.Call( + EnumerableMethods.GetAverageWithoutSelector(expression.Type.TryGetSequenceType()), expression); break; } @@ -551,7 +563,8 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp result = expression == null ? null - : Expression.Call(EnumerableMethods.GetSumWithoutSelector(expression.Type.TryGetSequenceType()), expression); + : Expression.Call( + EnumerableMethods.GetSumWithoutSelector(expression.Type.TryGetSequenceType()), expression); break; } @@ -605,7 +618,9 @@ Expression ApplySelect(GroupingElementExpression groupingElement) return result; } - static GroupingElementExpression ApplySelector(GroupingElementExpression groupingElement, LambdaExpression lambdaExpression) + static GroupingElementExpression ApplySelector( + GroupingElementExpression groupingElement, + LambdaExpression lambdaExpression) { var selector = RemapLambda(groupingElement, lambdaExpression); @@ -646,13 +661,14 @@ static Expression RemapLambda(GroupingElementExpression groupingElement, LambdaE } if (!(innerExpression is ProjectionBindingExpression projectionBindingExpression - && (convertedType == null + && (convertedType == null || convertedType.MakeNullable() == innerExpression.Type))) { return null; } - return ProcessSingleResultScalar(subquery.ServerQueryExpression, + return ProcessSingleResultScalar( + subquery.ServerQueryExpression, subquery.GetMappedProjection(projectionBindingExpression.ProjectionMember), subquery.CurrentParameter, methodCallExpression.Type); @@ -690,10 +706,11 @@ static Expression RemapLambda(GroupingElementExpression groupingElement, LambdaE var left = Visit(methodCallExpression.Object); var right = Visit(methodCallExpression.Arguments[0]); - if (TryRewriteEntityEquality(ExpressionType.Equal, - left ?? methodCallExpression.Object, - right ?? methodCallExpression.Arguments[0], - out var result)) + if (TryRewriteEntityEquality( + ExpressionType.Equal, + left ?? methodCallExpression.Object, + right ?? methodCallExpression.Arguments[0], + out var result)) { return result; } @@ -714,14 +731,16 @@ static Expression RemapLambda(GroupingElementExpression groupingElement, LambdaE if (methodCallExpression.Arguments[0].Type == typeof(object[]) && methodCallExpression.Arguments[0] is NewArrayExpression) { - return Visit(ConvertObjectArrayEqualityComparison( - methodCallExpression.Arguments[0], methodCallExpression.Arguments[1])); + return Visit( + ConvertObjectArrayEqualityComparison( + methodCallExpression.Arguments[0], methodCallExpression.Arguments[1])); } var left = Visit(methodCallExpression.Arguments[0]); var right = Visit(methodCallExpression.Arguments[1]); - if (TryRewriteEntityEquality(ExpressionType.Equal, + if (TryRewriteEntityEquality( + ExpressionType.Equal, left ?? methodCallExpression.Arguments[0], right ?? methodCallExpression.Arguments[1], out var result)) @@ -1099,7 +1118,10 @@ private Expression BindProperty(EntityReferenceExpression entityReferenceExpress } private static Expression ProcessSingleResultScalar( - Expression serverQuery, Expression readValueExpression, Expression valueBufferParameter, Type type) + Expression serverQuery, + Expression readValueExpression, + Expression valueBufferParameter, + Type type) { var singleResult = ((LambdaExpression)((NewExpression)serverQuery).Arguments[0]).Body; if (readValueExpression is UnaryExpression unaryExpression @@ -1195,7 +1217,8 @@ private bool TryRewriteContainsEntity(Expression source, Expression item, out Ex { case ConstantExpression constantExpression: var values = (IEnumerable)constantExpression.Value; - var propertyValueList = (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(property.ClrType.MakeNullable())); + var propertyValueList = + (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(property.ClrType.MakeNullable())); var propertyGetter = property.GetGetter(); foreach (var value in values) { @@ -1206,7 +1229,7 @@ private bool TryRewriteContainsEntity(Expression source, Expression item, out Ex break; case MethodCallExpression methodCallExpression - when methodCallExpression.Method.IsGenericMethod + when methodCallExpression.Method.IsGenericMethod && methodCallExpression.Method.GetGenericMethodDefinition() == _getParameterValueMethodInfo: var parameterName = (string)((ConstantExpression)methodCallExpression.Arguments[1]).Value; var lambda = Expression.Lambda( @@ -1219,8 +1242,8 @@ when methodCallExpression.Method.IsGenericMethod ); var newParameterName = - $"{_runtimeParameterPrefix}" + - $"{parameterName.Substring(QueryCompilationContext.QueryParameterPrefix.Length)}_{property.Name}"; + $"{_runtimeParameterPrefix}" + + $"{parameterName.Substring(QueryCompilationContext.QueryParameterPrefix.Length)}_{property.Name}"; rewrittenSource = _queryCompilationContext.RegisterRuntimeParameter(newParameterName, lambda); break; @@ -1229,10 +1252,11 @@ when methodCallExpression.Method.IsGenericMethod return false; } - result = Visit(Expression.Call( - EnumerableMethods.Contains.MakeGenericMethod(property.ClrType.MakeNullable()), - rewrittenSource, - CreatePropertyAccessExpression(item, property))); + result = Visit( + Expression.Call( + EnumerableMethods.Contains.MakeGenericMethod(property.ClrType.MakeNullable()), + rewrittenSource, + CreatePropertyAccessExpression(item, property))); return true; } @@ -1260,10 +1284,13 @@ private bool TryRewriteEntityEquality(ExpressionType nodeType, Expression left, throw new InvalidOperationException(CoreStrings.EntityEqualityOnKeylessEntityNotSupported(entityType1.DisplayName())); } - result = Visit(primaryKeyProperties1.Select(p => - Expression.MakeBinary( - nodeType, CreatePropertyAccessExpression(nonNullEntityReference, p), Expression.Constant(null, p.ClrType.MakeNullable()))) - .Aggregate((l, r) => nodeType == ExpressionType.Equal ? Expression.OrElse(l, r) : Expression.AndAlso(l, r))); + result = Visit( + primaryKeyProperties1.Select( + p => + Expression.MakeBinary( + nodeType, CreatePropertyAccessExpression(nonNullEntityReference, p), + Expression.Constant(null, p.ClrType.MakeNullable()))) + .Aggregate((l, r) => nodeType == ExpressionType.Equal ? Expression.OrElse(l, r) : Expression.AndAlso(l, r))); return true; } @@ -1296,11 +1323,13 @@ private bool TryRewriteEntityEquality(ExpressionType nodeType, Expression left, CoreStrings.EntityEqualitySubqueryWithCompositeKeyNotSupported(entityType.DisplayName())); } - result = Visit(primaryKeyProperties.Select(p => - Expression.MakeBinary( - nodeType, - CreatePropertyAccessExpression(left, p), - CreatePropertyAccessExpression(right, p))) + result = Visit( + primaryKeyProperties.Select( + p => + Expression.MakeBinary( + nodeType, + CreatePropertyAccessExpression(left, p), + CreatePropertyAccessExpression(right, p))) .Aggregate((l, r) => Expression.AndAlso(l, r))); return true; @@ -1315,7 +1344,7 @@ private Expression CreatePropertyAccessExpression(Expression target, IProperty p property.GetGetter().GetClrValue(constantExpression.Value), property.ClrType.MakeNullable()); case MethodCallExpression methodCallExpression - when methodCallExpression.Method.IsGenericMethod + when methodCallExpression.Method.IsGenericMethod && methodCallExpression.Method.GetGenericMethodDefinition() == _getParameterValueMethodInfo: var parameterName = (string)((ConstantExpression)methodCallExpression.Arguments[1]).Value; var lambda = Expression.Lambda( @@ -1327,24 +1356,24 @@ when methodCallExpression.Method.IsGenericMethod QueryCompilationContext.QueryContextParameter); var newParameterName = - $"{_runtimeParameterPrefix}" + - $"{parameterName.Substring(QueryCompilationContext.QueryParameterPrefix.Length)}_{property.Name}"; + $"{_runtimeParameterPrefix}" + + $"{parameterName.Substring(QueryCompilationContext.QueryParameterPrefix.Length)}_{property.Name}"; return _queryCompilationContext.RegisterRuntimeParameter(newParameterName, lambda); case MemberInitExpression memberInitExpression - when memberInitExpression.Bindings.SingleOrDefault( - mb => mb.Member.Name == property.Name) is MemberAssignment memberAssignment: + when memberInitExpression.Bindings.SingleOrDefault( + mb => mb.Member.Name == property.Name) is MemberAssignment memberAssignment: return memberAssignment.Expression.Type.IsNullableType() ? memberAssignment.Expression : Expression.Convert(memberAssignment.Expression, property.ClrType.MakeNullable()); case NewExpression newExpression - when CanEvaluate(newExpression): + when CanEvaluate(newExpression): return CreatePropertyAccessExpression(GetValue(newExpression), property); case MemberInitExpression memberInitExpression - when CanEvaluate(memberInitExpression): + when CanEvaluate(memberInitExpression): return CreatePropertyAccessExpression(GetValue(memberInitExpression), property); default: @@ -1359,7 +1388,9 @@ private static T ParameterValueExtractor(QueryContext context, string basePar } private static List ParameterListValueExtractor( - QueryContext context, string baseParameterName, IProperty property) + QueryContext context, + string baseParameterName, + IProperty property) { if (!(context.ParameterValues[baseParameterName] is IEnumerable baseListParameter)) { @@ -1425,8 +1456,8 @@ static Expression RemoveObjectConvert(Expression expression) => expression is UnaryExpression unaryExpression && expression.Type == typeof(object) && expression.NodeType == ExpressionType.Convert - ? unaryExpression.Operand - : expression; + ? unaryExpression.Operand + : expression; } private static bool IsNullConstantExpression(Expression expression) @@ -1575,8 +1606,11 @@ private EntityReferenceExpression(EntityReferenceExpression entityReferenceExpre public ShapedQueryExpression SubqueryEntity { get; } public IEntityType EntityType { get; } - public override Type Type => EntityType.ClrType; - public override ExpressionType NodeType => ExpressionType.Extension; + public override Type Type + => EntityType.ClrType; + + public override ExpressionType NodeType + => ExpressionType.Extension; public Expression Convert(Type type) { @@ -1600,16 +1634,19 @@ public GroupingElementExpression(Expression source, Expression selector, Paramet ValueBufferParameter = valueBufferParameter; Selector = selector; } + public Expression Source { get; private set; } public bool IsDistinct { get; private set; } public Expression Selector { get; private set; } public ParameterExpression ValueBufferParameter { get; } + public GroupingElementExpression ApplyDistinct() { IsDistinct = true; return this; } + public GroupingElementExpression ApplySelector(Expression expression) { Selector = expression; @@ -1624,8 +1661,11 @@ public GroupingElementExpression UpdateSource(Expression source) return this; } - public override Type Type => typeof(IEnumerable<>).MakeGenericType(Selector.Type); - public override ExpressionType NodeType => ExpressionType.Extension; + public override Type Type + => typeof(IEnumerable<>).MakeGenericType(Selector.Type); + + public override ExpressionType NodeType + => ExpressionType.Extension; } } } diff --git a/src/EFCore.InMemory/Query/Internal/InMemoryGroupByShaperExpression.cs b/src/EFCore.InMemory/Query/Internal/InMemoryGroupByShaperExpression.cs index b5e45bdd6f7..c8b1acf52f4 100644 --- a/src/EFCore.InMemory/Query/Internal/InMemoryGroupByShaperExpression.cs +++ b/src/EFCore.InMemory/Query/Internal/InMemoryGroupByShaperExpression.cs @@ -39,6 +39,7 @@ public InMemoryGroupByShaperExpression( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual ParameterExpression GroupingParameter { get; } + /// /// 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 diff --git a/src/EFCore.InMemory/Query/Internal/InMemoryProjectionBindingExpressionVisitor.cs b/src/EFCore.InMemory/Query/Internal/InMemoryProjectionBindingExpressionVisitor.cs index dcbc3cec828..4ac33316af2 100644 --- a/src/EFCore.InMemory/Query/Internal/InMemoryProjectionBindingExpressionVisitor.cs +++ b/src/EFCore.InMemory/Query/Internal/InMemoryProjectionBindingExpressionVisitor.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; -using System.Reflection; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -132,7 +131,7 @@ public override Expression Visit(Expression expression) && methodCallExpression.Method.Name == nameof(Enumerable.ToList)) { var subqueryTranslation = _queryableMethodTranslatingExpressionVisitor.TranslateSubquery( - methodCallExpression.Arguments[0]); + methodCallExpression.Arguments[0]); if (subqueryTranslation != null) { @@ -170,7 +169,7 @@ public override Expression Visit(Expression expression) return translation == null ? base.Visit(expression) : new ProjectionBindingExpression( - _queryExpression, _queryExpression.AddToProjection(translation), expression.Type.MakeNullable()); + _queryExpression, _queryExpression.AddToProjection(translation), expression.Type.MakeNullable()); } else { @@ -481,10 +480,10 @@ protected override Expression VisitUnary(UnaryExpression unaryExpression) var operand = Visit(unaryExpression.Operand); return (unaryExpression.NodeType == ExpressionType.Convert - || unaryExpression.NodeType == ExpressionType.ConvertChecked) + || unaryExpression.NodeType == ExpressionType.ConvertChecked) && unaryExpression.Type == operand.Type - ? operand - : unaryExpression.Update(MatchTypes(operand, unaryExpression.Operand.Type)); + ? operand + : unaryExpression.Update(MatchTypes(operand, unaryExpression.Operand.Type)); } // TODO: Debugging @@ -497,7 +496,9 @@ private void VerifyQueryExpression(ProjectionBindingExpression projectionBinding } private CollectionShaperExpression AddCollectionProjection( - ShapedQueryExpression subquery, INavigationBase navigation, Type elementType) + ShapedQueryExpression subquery, + INavigationBase navigation, + Type elementType) => new CollectionShaperExpression( new ProjectionBindingExpression( _queryExpression, diff --git a/src/EFCore.InMemory/Query/Internal/InMemoryQueryExpression.ResultEnumerable.cs b/src/EFCore.InMemory/Query/Internal/InMemoryQueryExpression.ResultEnumerable.cs index a41d40644bf..4f4f92e5610 100644 --- a/src/EFCore.InMemory/Query/Internal/InMemoryQueryExpression.ResultEnumerable.cs +++ b/src/EFCore.InMemory/Query/Internal/InMemoryQueryExpression.ResultEnumerable.cs @@ -19,9 +19,11 @@ public ResultEnumerable(Func getElement) _getElement = getElement; } - public IEnumerator GetEnumerator() => new ResultEnumerator(_getElement()); + public IEnumerator GetEnumerator() + => new ResultEnumerator(_getElement()); - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() + => GetEnumerator(); private sealed class ResultEnumerator : IEnumerator { @@ -51,9 +53,11 @@ public void Reset() _moved = false; } - object IEnumerator.Current => Current; + object IEnumerator.Current + => Current; - public ValueBuffer Current => !_moved ? ValueBuffer.Empty : _value; + public ValueBuffer Current + => !_moved ? ValueBuffer.Empty : _value; void IDisposable.Dispose() { diff --git a/src/EFCore.InMemory/Query/Internal/InMemoryQueryExpression.cs b/src/EFCore.InMemory/Query/Internal/InMemoryQueryExpression.cs index 9d14460626f..dd8ea804a6a 100644 --- a/src/EFCore.InMemory/Query/Internal/InMemoryQueryExpression.cs +++ b/src/EFCore.InMemory/Query/Internal/InMemoryQueryExpression.cs @@ -47,7 +47,9 @@ private readonly IDictionary - public virtual IReadOnlyList Projection => _valueBufferSlots; + public virtual IReadOnlyList Projection + => _valueBufferSlots; + /// /// 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 @@ -55,27 +57,33 @@ private readonly IDictionary public virtual Expression ServerQueryExpression { get; private set; } + /// /// 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 virtual ParameterExpression CurrentParameter => _groupingParameter ?? _valueBufferParameter; + public virtual ParameterExpression CurrentParameter + => _groupingParameter ?? _valueBufferParameter; + /// /// 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 override Type Type => typeof(IEnumerable); + public override Type Type + => typeof(IEnumerable); + /// /// 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 sealed override ExpressionType NodeType => ExpressionType.Extension; + public sealed override ExpressionType NodeType + => ExpressionType.Extension; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -111,7 +119,6 @@ public InMemoryQueryExpression([NotNull] IEntityType entityType) var entityProjection = new EntityProjectionExpression(entityType, readExpressionMap); _projectionMapping[new ProjectionMember()] = entityProjection; - } /// @@ -220,7 +227,9 @@ public virtual int AddToProjection([NotNull] Expression expression) /// 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 virtual int AddSubqueryProjection([NotNull] ShapedQueryExpression shapedQueryExpression, [CanBeNull] out Expression innerShaper) + public virtual int AddSubqueryProjection( + [NotNull] ShapedQueryExpression shapedQueryExpression, + [CanBeNull] out Expression innerShaper) { var subquery = (InMemoryQueryExpression)shapedQueryExpression.QueryExpression; subquery.ApplyProjection(); @@ -433,8 +442,8 @@ private static IPropertyBase InferPropertyFromInner(Expression expression) => expression is MethodCallExpression methodCallExpression && methodCallExpression.Method.IsGenericMethod && methodCallExpression.Method.GetGenericMethodDefinition() == ExpressionExtensions.ValueBufferTryReadValueMethod - ? (IPropertyBase)((ConstantExpression)methodCallExpression.Arguments[2]).Value - : null; + ? (IPropertyBase)((ConstantExpression)methodCallExpression.Arguments[2]).Value + : null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -490,7 +499,9 @@ public virtual void ApplyProjection() /// 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 virtual InMemoryGroupByShaperExpression ApplyGrouping([NotNull] Expression groupingKey, [NotNull] Expression shaperExpression) + public virtual InMemoryGroupByShaperExpression ApplyGrouping( + [NotNull] Expression groupingKey, + [NotNull] Expression shaperExpression) { PushdownIntoSubquery(); @@ -707,7 +718,7 @@ public virtual void AddLeftJoin( var projectionMapping = new Dictionary(); var replacingVisitor = new ReplacingExpressionVisitor( new Expression[] { CurrentParameter, innerQueryExpression.CurrentParameter }, - new Expression[] { MakeMemberAccess(outerParameter, outerMemberInfo), innerParameter}); + new Expression[] { MakeMemberAccess(outerParameter, outerMemberInfo), innerParameter }); var index = 0; outerMemberInfo = transparentIdentifierType.GetTypeInfo().GetDeclaredField("Outer"); @@ -803,7 +814,9 @@ public virtual void AddLeftJoin( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual void AddSelectMany( - [NotNull] InMemoryQueryExpression innerQueryExpression, [CanBeNull] Type transparentIdentifierType, bool innerNullable) + [NotNull] InMemoryQueryExpression innerQueryExpression, + [CanBeNull] Type transparentIdentifierType, + bool innerNullable) { var outerParameter = Parameter(typeof(ValueBuffer), "outer"); var innerParameter = Parameter(typeof(ValueBuffer), "inner"); @@ -941,7 +954,7 @@ public virtual EntityShaperExpression AddNavigationToWeakEntityType( var projectionMapping = new Dictionary(); var replacingVisitor = new ReplacingExpressionVisitor( new Expression[] { CurrentParameter, innerQueryExpression.CurrentParameter }, - new Expression[] { MakeMemberAccess(outerParameter, outerMemberInfo), innerParameter}); + new Expression[] { MakeMemberAccess(outerParameter, outerMemberInfo), innerParameter }); var index = 0; EntityProjectionExpression copyEntityProjectionToOuter(EntityProjectionExpression entityProjection) diff --git a/src/EFCore.InMemory/Query/Internal/InMemoryQueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore.InMemory/Query/Internal/InMemoryQueryableMethodTranslatingExpressionVisitor.cs index 2096eb16933..63b42f37ff4 100644 --- a/src/EFCore.InMemory/Query/Internal/InMemoryQueryableMethodTranslatingExpressionVisitor.cs +++ b/src/EFCore.InMemory/Query/Internal/InMemoryQueryableMethodTranslatingExpressionVisitor.cs @@ -353,7 +353,9 @@ protected override ShapedQueryExpression TranslateDistinct(ShapedQueryExpression /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ShapedQueryExpression TranslateElementAtOrDefault( - ShapedQueryExpression source, Expression index, bool returnDefault) + ShapedQueryExpression source, + Expression index, + bool returnDefault) { Check.NotNull(source, nameof(source)); Check.NotNull(index, nameof(index)); @@ -382,7 +384,10 @@ protected override ShapedQueryExpression TranslateExcept(ShapedQueryExpression s /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ShapedQueryExpression TranslateFirstOrDefault( - ShapedQueryExpression source, LambdaExpression predicate, Type returnType, bool returnDefault) + ShapedQueryExpression source, + LambdaExpression predicate, + Type returnType, + bool returnDefault) { Check.NotNull(source, nameof(source)); Check.NotNull(returnType, nameof(returnType)); @@ -403,7 +408,10 @@ protected override ShapedQueryExpression TranslateFirstOrDefault( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ShapedQueryExpression TranslateGroupBy( - ShapedQueryExpression source, LambdaExpression keySelector, LambdaExpression elementSelector, LambdaExpression resultSelector) + ShapedQueryExpression source, + LambdaExpression keySelector, + LambdaExpression elementSelector, + LambdaExpression resultSelector) { Check.NotNull(source, nameof(source)); Check.NotNull(keySelector, nameof(keySelector)); @@ -581,7 +589,10 @@ protected override ShapedQueryExpression TranslateJoin( } private (LambdaExpression OuterKeySelector, LambdaExpression InnerKeySelector) ProcessJoinKeySelector( - ShapedQueryExpression outer, ShapedQueryExpression inner, LambdaExpression outerKeySelector, LambdaExpression innerKeySelector) + ShapedQueryExpression outer, + ShapedQueryExpression inner, + LambdaExpression outerKeySelector, + LambdaExpression innerKeySelector) { var left = RemapLambdaBody(outer, outerKeySelector); var right = RemapLambdaBody(inner, innerKeySelector); @@ -625,9 +636,10 @@ static Expression CreateAnonymousObject(List expressions) expressions.Select(e => Expression.Convert(e, typeof(object))))); } - private static bool ProcessJoinCondition( - Expression joinCondition, List leftExpressions, List rightExpressions) + Expression joinCondition, + List leftExpressions, + List rightExpressions) { if (joinCondition is BinaryExpression binaryExpression) { @@ -681,7 +693,10 @@ static bool IsConvertedToNullable(Expression outer, Expression inner) /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ShapedQueryExpression TranslateLastOrDefault( - ShapedQueryExpression source, LambdaExpression predicate, Type returnType, bool returnDefault) + ShapedQueryExpression source, + LambdaExpression predicate, + Type returnType, + bool returnDefault) { Check.NotNull(source, nameof(source)); Check.NotNull(returnType, nameof(returnType)); @@ -702,7 +717,10 @@ protected override ShapedQueryExpression TranslateLastOrDefault( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ShapedQueryExpression TranslateLeftJoin( - ShapedQueryExpression outer, ShapedQueryExpression inner, LambdaExpression outerKeySelector, LambdaExpression innerKeySelector, + ShapedQueryExpression outer, + ShapedQueryExpression inner, + LambdaExpression outerKeySelector, + LambdaExpression innerKeySelector, LambdaExpression resultSelector) { Check.NotNull(outer, nameof(outer)); @@ -717,7 +735,6 @@ protected override ShapedQueryExpression TranslateLeftJoin( return null; } - var transparentIdentifierType = TransparentIdentifierFactory.Create( resultSelector.Parameters[0].Type, resultSelector.Parameters[1].Type); @@ -780,7 +797,9 @@ protected override ShapedQueryExpression TranslateLongCount(ShapedQueryExpressio /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ShapedQueryExpression TranslateMax( - ShapedQueryExpression source, LambdaExpression selector, Type resultType) + ShapedQueryExpression source, + LambdaExpression selector, + Type resultType) { Check.NotNull(source, nameof(source)); @@ -845,7 +864,7 @@ protected override ShapedQueryExpression TranslateOfType(ShapedQueryExpression s inMemoryQueryExpression.ReplaceProjectionMapping( new Dictionary { - { projectionMember, entityProjectionExpression.UpdateEntityType(derivedType) } + { projectionMember, entityProjectionExpression.UpdateEntityType(derivedType) } }); return source.UpdateShaperExpression(entityShaperExpression.WithEntityType(derivedType)); @@ -861,7 +880,9 @@ protected override ShapedQueryExpression TranslateOfType(ShapedQueryExpression s /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ShapedQueryExpression TranslateOrderBy( - ShapedQueryExpression source, LambdaExpression keySelector, bool ascending) + ShapedQueryExpression source, + LambdaExpression keySelector, + bool ascending) { Check.NotNull(source, nameof(source)); Check.NotNull(keySelector, nameof(keySelector)); @@ -942,7 +963,9 @@ protected override ShapedQueryExpression TranslateSelect(ShapedQueryExpression s /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ShapedQueryExpression TranslateSelectMany( - ShapedQueryExpression source, LambdaExpression collectionSelector, LambdaExpression resultSelector) + ShapedQueryExpression source, + LambdaExpression collectionSelector, + LambdaExpression resultSelector) { Check.NotNull(source, nameof(source)); Check.NotNull(collectionSelector, nameof(collectionSelector)); @@ -1028,7 +1051,10 @@ protected override ShapedQueryExpression TranslateSelectMany(ShapedQueryExpressi /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ShapedQueryExpression TranslateSingleOrDefault( - ShapedQueryExpression source, LambdaExpression predicate, Type returnType, bool returnDefault) + ShapedQueryExpression source, + LambdaExpression predicate, + Type returnType, + bool returnDefault) { Check.NotNull(source, nameof(source)); Check.NotNull(returnType, nameof(returnType)); @@ -1263,7 +1289,8 @@ public WeakEntityExpandingExpressionVisitor(InMemoryExpressionTranslatingExpress _expressionTranslator = expressionTranslator; } - public string TranslationErrorDetails => _expressionTranslator.TranslationErrorDetails; + public string TranslationErrorDetails + => _expressionTranslator.TranslationErrorDetails; public Expression Expand(InMemoryQueryExpression queryExpression, Expression lambdaBody) { @@ -1434,7 +1461,10 @@ ProjectionBindingExpression projectionBindingExpression } private ShapedQueryExpression TranslateScalarAggregate( - ShapedQueryExpression source, LambdaExpression selector, string methodName, Type returnType) + ShapedQueryExpression source, + LambdaExpression selector, + string methodName, + Type returnType) { var inMemoryQueryExpression = (InMemoryQueryExpression)source.QueryExpression; @@ -1472,7 +1502,10 @@ MethodInfo GetMethod() } private ShapedQueryExpression TranslateSingleResultOperator( - ShapedQueryExpression source, LambdaExpression predicate, Type returnType, MethodInfo method) + ShapedQueryExpression source, + LambdaExpression predicate, + Type returnType, + MethodInfo method) { var inMemoryQueryExpression = (InMemoryQueryExpression)source.QueryExpression; diff --git a/src/EFCore.InMemory/Query/Internal/InMemoryShapedQueryCompilingExpressionVisitor.InMemoryProjectionBindingRemovingExpressionVisitor.cs b/src/EFCore.InMemory/Query/Internal/InMemoryShapedQueryCompilingExpressionVisitor.InMemoryProjectionBindingRemovingExpressionVisitor.cs index fce4c902944..75440650364 100644 --- a/src/EFCore.InMemory/Query/Internal/InMemoryShapedQueryCompilingExpressionVisitor.InMemoryProjectionBindingRemovingExpressionVisitor.cs +++ b/src/EFCore.InMemory/Query/Internal/InMemoryShapedQueryCompilingExpressionVisitor.InMemoryProjectionBindingRemovingExpressionVisitor.cs @@ -70,7 +70,8 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp _materializationContextBindings[ (ParameterExpression)((MethodCallExpression)methodCallExpression.Arguments[0]).Object]; - Check.DebugAssert(property != null || methodCallExpression.Type.IsNullableType(), "Must read nullable value without property"); + Check.DebugAssert( + property != null || methodCallExpression.Type.IsNullableType(), "Must read nullable value without property"); return Expression.Call( methodCallExpression.Method, @@ -93,7 +94,9 @@ protected override Expression VisitExtension(Expression extensionExpression) var valueBuffer = queryExpression.CurrentParameter; var property = InferPropertyFromInner(queryExpression.Projection[projectionIndex]); - Check.DebugAssert(property != null || projectionBindingExpression.Type.IsNullableType() + Check.DebugAssert( + property != null + || projectionBindingExpression.Type.IsNullableType() || projectionBindingExpression.Type == typeof(ValueBuffer), "Must read nullable value without property"); return valueBuffer.CreateValueBufferReadValueExpression(projectionBindingExpression.Type, projectionIndex, property); @@ -115,7 +118,8 @@ private IPropertyBase InferPropertyFromInner(Expression expression) } private object GetProjectionIndex( - InMemoryQueryExpression queryExpression, ProjectionBindingExpression projectionBindingExpression) + InMemoryQueryExpression queryExpression, + ProjectionBindingExpression projectionBindingExpression) { return projectionBindingExpression.ProjectionMember != null ? ((ConstantExpression)queryExpression.GetMappedProjection(projectionBindingExpression.ProjectionMember)).Value diff --git a/src/EFCore.InMemory/Query/Internal/InMemoryShapedQueryCompilingExpressionVisitor.QueryingEnumerable.cs b/src/EFCore.InMemory/Query/Internal/InMemoryShapedQueryCompilingExpressionVisitor.QueryingEnumerable.cs index 35f00489dab..216ac490a36 100644 --- a/src/EFCore.InMemory/Query/Internal/InMemoryShapedQueryCompilingExpressionVisitor.QueryingEnumerable.cs +++ b/src/EFCore.InMemory/Query/Internal/InMemoryShapedQueryCompilingExpressionVisitor.QueryingEnumerable.cs @@ -50,11 +50,14 @@ public QueryingEnumerable( public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default) => new Enumerator(this, cancellationToken); - public IEnumerator GetEnumerator() => new Enumerator(this); + public IEnumerator GetEnumerator() + => new Enumerator(this); - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() + => GetEnumerator(); - public string ToQueryString() => InMemoryStrings.NoQueryStrings; + public string ToQueryString() + => InMemoryStrings.NoQueryStrings; private sealed class Enumerator : IEnumerator, IAsyncEnumerator { @@ -80,7 +83,8 @@ public Enumerator(QueryingEnumerable queryingEnumerable, CancellationToken ca public T Current { get; private set; } - object IEnumerator.Current => Current; + object IEnumerator.Current + => Current; public bool MoveNext() { @@ -151,7 +155,8 @@ public ValueTask DisposeAsync() return enumerator.DisposeAsyncIfAvailable(); } - public void Reset() => throw new NotImplementedException(); + public void Reset() + => throw new NotImplementedException(); } } } diff --git a/src/EFCore.InMemory/Query/Internal/InMemoryShapedQueryCompilingExpressionVisitor.cs b/src/EFCore.InMemory/Query/Internal/InMemoryShapedQueryCompilingExpressionVisitor.cs index 53972f05fd3..c55301e6ea5 100644 --- a/src/EFCore.InMemory/Query/Internal/InMemoryShapedQueryCompilingExpressionVisitor.cs +++ b/src/EFCore.InMemory/Query/Internal/InMemoryShapedQueryCompilingExpressionVisitor.cs @@ -6,7 +6,6 @@ using System.Linq.Expressions; using System.Reflection; using JetBrains.Annotations; -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Storage; @@ -91,7 +90,8 @@ protected override Expression VisitShapedQuery(ShapedQueryExpression shapedQuery innerEnumerable, Expression.Constant(shaperLambda.Compile()), Expression.Constant(_contextType), - Expression.Constant(QueryCompilationContext.QueryTrackingBehavior == QueryTrackingBehavior.NoTrackingWithIdentityResolution)); + Expression.Constant( + QueryCompilationContext.QueryTrackingBehavior == QueryTrackingBehavior.NoTrackingWithIdentityResolution)); } private static readonly MethodInfo _tableMethodInfo diff --git a/src/EFCore.InMemory/Query/Internal/InMemoryShapedQueryExpressionVisitorFactory.cs b/src/EFCore.InMemory/Query/Internal/InMemoryShapedQueryExpressionVisitorFactory.cs index 89eecd3b95b..f7ac72cc406 100644 --- a/src/EFCore.InMemory/Query/Internal/InMemoryShapedQueryExpressionVisitorFactory.cs +++ b/src/EFCore.InMemory/Query/Internal/InMemoryShapedQueryExpressionVisitorFactory.cs @@ -23,7 +23,8 @@ public class InMemoryShapedQueryCompilingExpressionVisitorFactory : IShapedQuery /// 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 InMemoryShapedQueryCompilingExpressionVisitorFactory([NotNull] ShapedQueryCompilingExpressionVisitorDependencies dependencies) + public InMemoryShapedQueryCompilingExpressionVisitorFactory( + [NotNull] ShapedQueryCompilingExpressionVisitorDependencies dependencies) { _dependencies = dependencies; } diff --git a/src/EFCore.InMemory/Query/Internal/InMemoryTableExpression.cs b/src/EFCore.InMemory/Query/Internal/InMemoryTableExpression.cs index 1be1b897e9a..d963b5adb6e 100644 --- a/src/EFCore.InMemory/Query/Internal/InMemoryTableExpression.cs +++ b/src/EFCore.InMemory/Query/Internal/InMemoryTableExpression.cs @@ -37,7 +37,8 @@ public InMemoryTableExpression([NotNull] IEntityType entityType) /// 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 override Type Type => typeof(IEnumerable); + public override Type Type + => typeof(IEnumerable); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -53,7 +54,8 @@ public InMemoryTableExpression([NotNull] IEntityType entityType) /// 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 sealed override ExpressionType NodeType => ExpressionType.Extension; + public sealed override ExpressionType NodeType + => ExpressionType.Extension; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.InMemory/Query/Internal/ShaperExpressionProcessingExpressionVisitor.cs b/src/EFCore.InMemory/Query/Internal/ShaperExpressionProcessingExpressionVisitor.cs index d87e92ab261..446ea91d876 100644 --- a/src/EFCore.InMemory/Query/Internal/ShaperExpressionProcessingExpressionVisitor.cs +++ b/src/EFCore.InMemory/Query/Internal/ShaperExpressionProcessingExpressionVisitor.cs @@ -31,7 +31,8 @@ public class ShaperExpressionProcessingExpressionVisitor : ExpressionVisitor /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public ShaperExpressionProcessingExpressionVisitor( - [CanBeNull] InMemoryQueryExpression queryExpression, [NotNull] ParameterExpression valueBufferParameter) + [CanBeNull] InMemoryQueryExpression queryExpression, + [NotNull] ParameterExpression valueBufferParameter) { _queryExpression = queryExpression; _valueBufferParameter = valueBufferParameter; diff --git a/src/EFCore.InMemory/Query/Internal/SingleResultShaperExpression.cs b/src/EFCore.InMemory/Query/Internal/SingleResultShaperExpression.cs index acd6bbc7e32..43c1e236860 100644 --- a/src/EFCore.InMemory/Query/Internal/SingleResultShaperExpression.cs +++ b/src/EFCore.InMemory/Query/Internal/SingleResultShaperExpression.cs @@ -66,7 +66,9 @@ public virtual SingleResultShaperExpression Update([NotNull] Expression projecti /// 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 sealed override ExpressionType NodeType => ExpressionType.Extension; + public sealed override ExpressionType NodeType + => ExpressionType.Extension; + /// /// 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 @@ -82,6 +84,7 @@ public virtual SingleResultShaperExpression Update([NotNull] Expression projecti /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual Expression Projection { get; } + /// /// 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 diff --git a/src/EFCore.InMemory/Storage/Internal/IInMemoryStore.cs b/src/EFCore.InMemory/Storage/Internal/IInMemoryStore.cs index 98c1a002839..b124ad953d1 100644 --- a/src/EFCore.InMemory/Storage/Internal/IInMemoryStore.cs +++ b/src/EFCore.InMemory/Storage/Internal/IInMemoryStore.cs @@ -59,6 +59,7 @@ bool EnsureCreated( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// int ExecuteTransaction( - [NotNull] IList entries, [NotNull] IDiagnosticsLogger updateLogger); + [NotNull] IList entries, + [NotNull] IDiagnosticsLogger updateLogger); } } diff --git a/src/EFCore.InMemory/Storage/Internal/IInMemoryTable.cs b/src/EFCore.InMemory/Storage/Internal/IInMemoryTable.cs index f997dcd6fff..7f117d483d2 100644 --- a/src/EFCore.InMemory/Storage/Internal/IInMemoryTable.cs +++ b/src/EFCore.InMemory/Storage/Internal/IInMemoryTable.cs @@ -64,7 +64,8 @@ public interface IInMemoryTable /// doing so can result in application failures when updating to a new Entity Framework Core release. /// InMemoryIntegerValueGenerator GetIntegerValueGenerator( - [NotNull] IProperty property, [NotNull] IReadOnlyList tables); + [NotNull] IProperty property, + [NotNull] IReadOnlyList tables); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.InMemory/Storage/Internal/InMemoryDatabase.cs b/src/EFCore.InMemory/Storage/Internal/InMemoryDatabase.cs index 19d6e50395b..7da88972b8e 100644 --- a/src/EFCore.InMemory/Storage/Internal/InMemoryDatabase.cs +++ b/src/EFCore.InMemory/Storage/Internal/InMemoryDatabase.cs @@ -64,7 +64,8 @@ public InMemoryDatabase( /// 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 virtual IInMemoryStore Store => _store; + public virtual IInMemoryStore Store + => _store; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.InMemory/Storage/Internal/InMemoryDatabaseCreator.cs b/src/EFCore.InMemory/Storage/Internal/InMemoryDatabaseCreator.cs index e3b4a7fa2e3..28f04febe64 100644 --- a/src/EFCore.InMemory/Storage/Internal/InMemoryDatabaseCreator.cs +++ b/src/EFCore.InMemory/Storage/Internal/InMemoryDatabaseCreator.cs @@ -47,7 +47,8 @@ public InMemoryDatabaseCreator([NotNull] IDatabase database) /// 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. /// - protected virtual IInMemoryDatabase Database => (IInMemoryDatabase)_database; + protected virtual IInMemoryDatabase Database + => (IInMemoryDatabase)_database; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -73,7 +74,8 @@ public virtual Task EnsureDeletedAsync(CancellationToken cancellationToken /// 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 virtual bool EnsureCreated() => Database.EnsureDatabaseCreated(); + public virtual bool EnsureCreated() + => Database.EnsureDatabaseCreated(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.InMemory/Storage/Internal/InMemoryStore.cs b/src/EFCore.InMemory/Storage/Internal/InMemoryStore.cs index 777ea37de53..bb080437f13 100644 --- a/src/EFCore.InMemory/Storage/Internal/InMemoryStore.cs +++ b/src/EFCore.InMemory/Storage/Internal/InMemoryStore.cs @@ -227,7 +227,6 @@ private IInMemoryTable EnsureTable(IEntityType entityType) baseTable = table; } - return _tables[_useNameMatching ? (object)entityType.FullName() : entityType]; } } diff --git a/src/EFCore.InMemory/Storage/Internal/InMemoryTable.cs b/src/EFCore.InMemory/Storage/Internal/InMemoryTable.cs index 18a775b7eca..5e94d32626a 100644 --- a/src/EFCore.InMemory/Storage/Internal/InMemoryTable.cs +++ b/src/EFCore.InMemory/Storage/Internal/InMemoryTable.cs @@ -58,6 +58,7 @@ public InMemoryTable([NotNull] IEntityType entityType, [CanBeNull] IInMemoryTabl { _valueConverters = new List<(int, ValueConverter)>(); } + _valueConverters.Add((property.GetIndex(), converter)); } @@ -68,6 +69,7 @@ public InMemoryTable([NotNull] IEntityType entityType, [CanBeNull] IInMemoryTabl { _valueComparers = new List<(int, ValueComparer)>(); } + _valueComparers.Add((property.GetIndex(), comparer)); } } @@ -96,7 +98,8 @@ public InMemoryTable([NotNull] IEntityType entityType, [CanBeNull] IInMemoryTabl /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual InMemoryIntegerValueGenerator GetIntegerValueGenerator( - IProperty property, IReadOnlyList tables) + IProperty property, + IReadOnlyList tables) { if (_integerGenerators == null) { @@ -127,7 +130,8 @@ public virtual InMemoryIntegerValueGenerator GetIntegerValueGenerator /// 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 virtual IEnumerable Rows => _rows.Values; + public virtual IEnumerable Rows + => _rows.Values; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -338,7 +342,8 @@ private static object SnapshotValue(ValueComparer comparer, object value) /// The update entry which resulted in the conflict(s). /// The conflicting properties with their associated database values. protected virtual void ThrowUpdateConcurrencyException( - [NotNull] IUpdateEntry entry, [NotNull] Dictionary concurrencyConflicts) + [NotNull] IUpdateEntry entry, + [NotNull] Dictionary concurrencyConflicts) { Check.NotNull(entry, nameof(entry)); Check.NotNull(concurrencyConflicts, nameof(concurrencyConflicts)); diff --git a/src/EFCore.InMemory/Storage/Internal/InMemoryTableFactory.cs b/src/EFCore.InMemory/Storage/Internal/InMemoryTableFactory.cs index f856db908df..76a64e33673 100644 --- a/src/EFCore.InMemory/Storage/Internal/InMemoryTableFactory.cs +++ b/src/EFCore.InMemory/Storage/Internal/InMemoryTableFactory.cs @@ -54,7 +54,9 @@ private Func CreateTable([NotNull] IEntityType entityType, IInMe [UsedImplicitly] private static Func CreateFactory( - IEntityType entityType, IInMemoryTable baseTable, bool sensitiveLoggingEnabled) + IEntityType entityType, + IInMemoryTable baseTable, + bool sensitiveLoggingEnabled) => () => new InMemoryTable(entityType, baseTable, sensitiveLoggingEnabled); } } diff --git a/src/EFCore.InMemory/Storage/Internal/InMemoryTransactionManager.cs b/src/EFCore.InMemory/Storage/Internal/InMemoryTransactionManager.cs index 77f393e5c86..08bf32abf31 100644 --- a/src/EFCore.InMemory/Storage/Internal/InMemoryTransactionManager.cs +++ b/src/EFCore.InMemory/Storage/Internal/InMemoryTransactionManager.cs @@ -80,7 +80,8 @@ public virtual Task BeginTransactionAsync( /// 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 virtual void CommitTransaction() => _logger.TransactionIgnoredWarning(); + public virtual void CommitTransaction() + => _logger.TransactionIgnoredWarning(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -100,7 +101,8 @@ public virtual Task CommitTransactionAsync(CancellationToken cancellationToken = /// 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 virtual void RollbackTransaction() => _logger.TransactionIgnoredWarning(); + public virtual void RollbackTransaction() + => _logger.TransactionIgnoredWarning(); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -120,7 +122,8 @@ public virtual Task RollbackTransactionAsync(CancellationToken cancellationToken /// 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 virtual IDbContextTransaction CurrentTransaction => null; + public virtual IDbContextTransaction CurrentTransaction + => null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -128,7 +131,8 @@ public virtual Task RollbackTransactionAsync(CancellationToken cancellationToken /// 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 virtual Transaction EnlistedTransaction => null; + public virtual Transaction EnlistedTransaction + => null; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.InMemory/ValueGeneration/Internal/InMemoryIntegerValueGenerator.cs b/src/EFCore.InMemory/ValueGeneration/Internal/InMemoryIntegerValueGenerator.cs index 81135b13052..dfc79294209 100644 --- a/src/EFCore.InMemory/ValueGeneration/Internal/InMemoryIntegerValueGenerator.cs +++ b/src/EFCore.InMemory/ValueGeneration/Internal/InMemoryIntegerValueGenerator.cs @@ -65,6 +65,7 @@ public override TValue Next(EntityEntry entry) /// 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 override bool GeneratesTemporaryValues => false; + public override bool GeneratesTemporaryValues + => false; } } diff --git a/src/EFCore.SqlServer.NTS/Infrastructure/Internal/SqlServerNetTopologySuiteOptionsExtension.cs b/src/EFCore.SqlServer.NTS/Infrastructure/Internal/SqlServerNetTopologySuiteOptionsExtension.cs index 55b62afe55a..d20f9c1176e 100644 --- a/src/EFCore.SqlServer.NTS/Infrastructure/Internal/SqlServerNetTopologySuiteOptionsExtension.cs +++ b/src/EFCore.SqlServer.NTS/Infrastructure/Internal/SqlServerNetTopologySuiteOptionsExtension.cs @@ -70,14 +70,17 @@ public ExtensionInfo(IDbContextOptionsExtension extension) private new SqlServerNetTopologySuiteOptionsExtension Extension => (SqlServerNetTopologySuiteOptionsExtension)base.Extension; - public override bool IsDatabaseProvider => false; + public override bool IsDatabaseProvider + => false; - public override long GetServiceProviderHashCode() => 0; + public override long GetServiceProviderHashCode() + => 0; public override void PopulateDebugInfo(IDictionary debugInfo) => debugInfo["SqlServer:" + nameof(SqlServerNetTopologySuiteDbContextOptionsBuilderExtensions.UseNetTopologySuite)] = "1"; - public override string LogFragment => "using NetTopologySuite "; + public override string LogFragment + => "using NetTopologySuite "; } } } diff --git a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryCollectionMemberTranslator.cs b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryCollectionMemberTranslator.cs index 3f7a0d27bcf..e0441c8cd22 100644 --- a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryCollectionMemberTranslator.cs +++ b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryCollectionMemberTranslator.cs @@ -40,7 +40,11 @@ public SqlServerGeometryCollectionMemberTranslator([NotNull] ISqlExpressionFacto /// 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 virtual SqlExpression Translate(SqlExpression instance, MemberInfo member, Type returnType, IDiagnosticsLogger logger) + public virtual SqlExpression Translate( + SqlExpression instance, + MemberInfo member, + Type returnType, + IDiagnosticsLogger logger) { Check.NotNull(member, nameof(member)); Check.NotNull(returnType, nameof(returnType)); diff --git a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryCollectionMethodTranslator.cs b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryCollectionMethodTranslator.cs index 3a09a4c7260..178e03c40c6 100644 --- a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryCollectionMethodTranslator.cs +++ b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryCollectionMethodTranslator.cs @@ -46,7 +46,10 @@ public SqlServerGeometryCollectionMethodTranslator( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) + SqlExpression instance, + MethodInfo method, + IReadOnlyList arguments, + IDiagnosticsLogger logger) { Check.NotNull(method, nameof(method)); Check.NotNull(arguments, nameof(arguments)); diff --git a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryMemberTranslator.cs b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryMemberTranslator.cs index f91dba96050..52f81fe8446 100644 --- a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryMemberTranslator.cs +++ b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryMemberTranslator.cs @@ -71,7 +71,10 @@ public SqlServerGeometryMemberTranslator( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MemberInfo member, Type returnType, IDiagnosticsLogger logger) + SqlExpression instance, + MemberInfo member, + Type returnType, + IDiagnosticsLogger logger) { Check.NotNull(member, nameof(member)); Check.NotNull(returnType, nameof(returnType)); diff --git a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryMethodTranslator.cs b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryMethodTranslator.cs index 0f57dc29983..3e349a22c06 100644 --- a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryMethodTranslator.cs +++ b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerGeometryMethodTranslator.cs @@ -81,7 +81,10 @@ public SqlServerGeometryMethodTranslator( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) + SqlExpression instance, + MethodInfo method, + IReadOnlyList arguments, + IDiagnosticsLogger logger) { Check.NotNull(method, nameof(method)); Check.NotNull(arguments, nameof(arguments)); diff --git a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerLineStringMemberTranslator.cs b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerLineStringMemberTranslator.cs index e639687f534..ed28212410b 100644 --- a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerLineStringMemberTranslator.cs +++ b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerLineStringMemberTranslator.cs @@ -56,7 +56,10 @@ public SqlServerLineStringMemberTranslator( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MemberInfo member, Type returnType, IDiagnosticsLogger logger) + SqlExpression instance, + MemberInfo member, + Type returnType, + IDiagnosticsLogger logger) { Check.NotNull(member, nameof(member)); Check.NotNull(returnType, nameof(returnType)); diff --git a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerLineStringMethodTranslator.cs b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerLineStringMethodTranslator.cs index 07bb6018b92..64fd1aa428c 100644 --- a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerLineStringMethodTranslator.cs +++ b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerLineStringMethodTranslator.cs @@ -48,7 +48,10 @@ public SqlServerLineStringMethodTranslator( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) + SqlExpression instance, + MethodInfo method, + IReadOnlyList arguments, + IDiagnosticsLogger logger) { Check.NotNull(method, nameof(method)); Check.NotNull(arguments, nameof(arguments)); diff --git a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerMultiLineStringMemberTranslator.cs b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerMultiLineStringMemberTranslator.cs index 7978604c26d..4e8b0584d1b 100644 --- a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerMultiLineStringMemberTranslator.cs +++ b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerMultiLineStringMemberTranslator.cs @@ -41,7 +41,10 @@ public SqlServerMultiLineStringMemberTranslator([NotNull] ISqlExpressionFactory /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MemberInfo member, Type returnType, IDiagnosticsLogger logger) + SqlExpression instance, + MemberInfo member, + Type returnType, + IDiagnosticsLogger logger) { Check.NotNull(member, nameof(member)); Check.NotNull(returnType, nameof(returnType)); diff --git a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerNetTopologySuiteMemberTranslatorPlugin.cs b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerNetTopologySuiteMemberTranslatorPlugin.cs index 8ad887a52a2..6418a421ea2 100644 --- a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerNetTopologySuiteMemberTranslatorPlugin.cs +++ b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerNetTopologySuiteMemberTranslatorPlugin.cs @@ -31,7 +31,8 @@ public class SqlServerNetTopologySuiteMemberTranslatorPlugin : IMemberTranslator /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public SqlServerNetTopologySuiteMemberTranslatorPlugin( - [NotNull] IRelationalTypeMappingSource typeMappingSource, [NotNull] ISqlExpressionFactory sqlExpressionFactory) + [NotNull] IRelationalTypeMappingSource typeMappingSource, + [NotNull] ISqlExpressionFactory sqlExpressionFactory) { Translators = new IMemberTranslator[] { diff --git a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerPointMemberTranslator.cs b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerPointMemberTranslator.cs index 3333bb56ca9..04e028d6ee6 100644 --- a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerPointMemberTranslator.cs +++ b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerPointMemberTranslator.cs @@ -37,7 +37,10 @@ public SqlServerPointMemberTranslator(ISqlExpressionFactory sqlExpressionFactory } public SqlExpression Translate( - SqlExpression instance, MemberInfo member, Type returnType, IDiagnosticsLogger logger) + SqlExpression instance, + MemberInfo member, + Type returnType, + IDiagnosticsLogger logger) { Check.NotNull(member, nameof(member)); Check.NotNull(returnType, nameof(returnType)); diff --git a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerPolygonMemberTranslator.cs b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerPolygonMemberTranslator.cs index f655fa75e49..f5cb649ace9 100644 --- a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerPolygonMemberTranslator.cs +++ b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerPolygonMemberTranslator.cs @@ -54,7 +54,10 @@ public SqlServerPolygonMemberTranslator( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MemberInfo member, Type returnType, IDiagnosticsLogger logger) + SqlExpression instance, + MemberInfo member, + Type returnType, + IDiagnosticsLogger logger) { Check.NotNull(member, nameof(member)); Check.NotNull(returnType, nameof(returnType)); diff --git a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerPolygonMethodTranslator.cs b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerPolygonMethodTranslator.cs index 38b7b7a6a61..b6baf7dd91f 100644 --- a/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerPolygonMethodTranslator.cs +++ b/src/EFCore.SqlServer.NTS/Query/Internal/SqlServerPolygonMethodTranslator.cs @@ -49,7 +49,10 @@ public SqlServerPolygonMethodTranslator( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) + SqlExpression instance, + MethodInfo method, + IReadOnlyList arguments, + IDiagnosticsLogger logger) { Check.NotNull(method, nameof(method)); Check.NotNull(arguments, nameof(arguments)); diff --git a/src/EFCore.SqlServer/Design/Internal/SqlServerAnnotationCodeGenerator.cs b/src/EFCore.SqlServer/Design/Internal/SqlServerAnnotationCodeGenerator.cs index 725033c9884..08397401ca3 100644 --- a/src/EFCore.SqlServer/Design/Internal/SqlServerAnnotationCodeGenerator.cs +++ b/src/EFCore.SqlServer/Design/Internal/SqlServerAnnotationCodeGenerator.cs @@ -38,7 +38,9 @@ public SqlServerAnnotationCodeGenerator([NotNull] AnnotationCodeGeneratorDepende /// 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 override IReadOnlyList GenerateFluentApiCalls(IModel model, IDictionary annotations) + public override IReadOnlyList GenerateFluentApiCalls( + IModel model, + IDictionary annotations) => base.GenerateFluentApiCalls(model, annotations) .Concat(GenerateValueGenerationStrategy(annotations, onModel: true)) .ToList(); @@ -49,7 +51,9 @@ public override IReadOnlyList GenerateFluentApiCalls(IMo /// 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 override IReadOnlyList GenerateFluentApiCalls(IProperty property, IDictionary annotations) + public override IReadOnlyList GenerateFluentApiCalls( + IProperty property, + IDictionary annotations) => base.GenerateFluentApiCalls(property, annotations) .Concat(GenerateValueGenerationStrategy(annotations, onModel: false)) .ToList(); @@ -110,7 +114,8 @@ protected override MethodCallCodeFragment GenerateFluentApi(IIndex index, IAnnot }; private IReadOnlyList GenerateValueGenerationStrategy( - IDictionary annotations, bool onModel) + IDictionary annotations, + bool onModel) { var strategy = GetAndRemove(SqlServerAnnotationNames.ValueGenerationStrategy); diff --git a/src/EFCore.SqlServer/Diagnostics/SqlServerEventId.cs b/src/EFCore.SqlServer/Diagnostics/SqlServerEventId.cs index 4699da6543b..702e7bd9895 100644 --- a/src/EFCore.SqlServer/Diagnostics/SqlServerEventId.cs +++ b/src/EFCore.SqlServer/Diagnostics/SqlServerEventId.cs @@ -63,7 +63,9 @@ private enum Id } private static readonly string _validationPrefix = DbLoggerCategory.Model.Validation.Name + "."; - private static EventId MakeValidationId(Id id) => new EventId((int)id, _validationPrefix + id); + + private static EventId MakeValidationId(Id id) + => new EventId((int)id, _validationPrefix + id); /// /// @@ -116,10 +118,13 @@ private enum Id /// payload when used with a . /// /// - public static readonly EventId ConflictingValueGenerationStrategiesWarning = MakeValidationId(Id.ConflictingValueGenerationStrategiesWarning); + public static readonly EventId ConflictingValueGenerationStrategiesWarning = + MakeValidationId(Id.ConflictingValueGenerationStrategiesWarning); private static readonly string _scaffoldingPrefix = DbLoggerCategory.Scaffolding.Name + "."; - private static EventId MakeScaffoldingId(Id id) => new EventId((int)id, _scaffoldingPrefix + id); + + private static EventId MakeScaffoldingId(Id id) + => new EventId((int)id, _scaffoldingPrefix + id); /// /// A column was found. diff --git a/src/EFCore.SqlServer/Extensions/SqlServerDatabaseFacadeExtensions.cs b/src/EFCore.SqlServer/Extensions/SqlServerDatabaseFacadeExtensions.cs index 192709a7501..1ab964889c1 100644 --- a/src/EFCore.SqlServer/Extensions/SqlServerDatabaseFacadeExtensions.cs +++ b/src/EFCore.SqlServer/Extensions/SqlServerDatabaseFacadeExtensions.cs @@ -16,7 +16,7 @@ public static class SqlServerDatabaseFacadeExtensions { /// /// - /// Returns if the database provider currently in use is the SQL Server provider. + /// Returns if the database provider currently in use is the SQL Server provider. /// /// /// This method can only be used after the has been configured because @@ -26,7 +26,7 @@ public static class SqlServerDatabaseFacadeExtensions /// /// /// The facade from . - /// if SQL Server is being used; otherwise. + /// if SQL Server is being used; otherwise. public static bool IsSqlServer([NotNull] this DatabaseFacade database) => database.ProviderName.Equals( typeof(SqlServerOptionsExtension).Assembly.GetName().Name, diff --git a/src/EFCore.SqlServer/Extensions/SqlServerDbContextOptionsBuilderExtensions.cs b/src/EFCore.SqlServer/Extensions/SqlServerDbContextOptionsBuilderExtensions.cs index cc3e36c0a51..285b5bd9f18 100644 --- a/src/EFCore.SqlServer/Extensions/SqlServerDbContextOptionsBuilderExtensions.cs +++ b/src/EFCore.SqlServer/Extensions/SqlServerDbContextOptionsBuilderExtensions.cs @@ -169,11 +169,9 @@ var coreOptionsExtension = optionsBuilder.Options.FindExtension() ?? new CoreOptionsExtension(); - coreOptionsExtension = coreOptionsExtension. - WithWarningsConfiguration( + coreOptionsExtension = coreOptionsExtension.WithWarningsConfiguration( coreOptionsExtension.WarningsConfiguration.TryWithExplicit( - RelationalEventId.AmbientTransactionWarning, WarningBehavior.Throw)). - WithWarningsConfiguration( + RelationalEventId.AmbientTransactionWarning, WarningBehavior.Throw)).WithWarningsConfiguration( coreOptionsExtension.WarningsConfiguration.TryWithExplicit( SqlServerEventId.ConflictingValueGenerationStrategiesWarning, WarningBehavior.Throw)); diff --git a/src/EFCore.SqlServer/Extensions/SqlServerDbFunctionsExtensions.cs b/src/EFCore.SqlServer/Extensions/SqlServerDbFunctionsExtensions.cs index 30ab9fb03ee..665bd23c2d6 100644 --- a/src/EFCore.SqlServer/Extensions/SqlServerDbFunctionsExtensions.cs +++ b/src/EFCore.SqlServer/Extensions/SqlServerDbFunctionsExtensions.cs @@ -832,7 +832,8 @@ public static bool IsDate( => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(IsDate))); /// - /// Initializes a new instance of the structure to the specified year, month, day, hour, minute, second, and millisecond. + /// Initializes a new instance of the structure to the specified year, month, day, hour, minute, second, and + /// millisecond. /// Corresponds to the SQL Server's DATETIMEFROMPARTS(year, month, day, hour, minute, second, millisecond). /// /// The DbFunctions instance. @@ -872,7 +873,8 @@ public static DateTime DateFromParts( => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateFromParts))); /// - /// Initializes a new instance of the structure to the specified year, month, day, hour, minute, second, fractions, and precision. + /// Initializes a new instance of the structure to the specified year, month, day, hour, minute, second, fractions, + /// and precision. /// Corresponds to the SQL Server's DATETIME2FROMPARTS (year, month, day, hour, minute, seconds, fractions, precision). /// /// The DbFunctions instance. @@ -884,7 +886,10 @@ public static DateTime DateFromParts( /// The seconds (0 through 59). /// The fractional seconds (0 through 9999999). /// The precision of the datetime2 value (0 through 7). - /// New instance of the structure to the specified year, month, day, hour, minute, second, fractions, and precision. + /// + /// New instance of the structure to the specified year, month, day, hour, minute, second, fractions, and + /// precision. + /// public static DateTime DateTime2FromParts( [CanBeNull] this DbFunctions _, int year, @@ -898,8 +903,10 @@ public static DateTime DateTime2FromParts( => throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(DateTime2FromParts))); /// - /// Initializes a new instance of the structure to the specified year, month, day, hour, minute, second, fractions, hourOffset, minuteOffset and precision. - /// Corresponds to the SQL Server's DATETIMEOFFSETFROMPARTS (year, month, day, hour, minute, seconds, fractions, hour_offset, minute_offset, precision). + /// Initializes a new instance of the structure to the specified year, month, day, hour, minute, second, + /// fractions, hourOffset, minuteOffset and precision. + /// Corresponds to the SQL Server's DATETIMEOFFSETFROMPARTS (year, month, day, hour, minute, seconds, fractions, hour_offset, + /// minute_offset, precision). /// /// The DbFunctions instance. /// The year (1753 through 9999). @@ -912,7 +919,10 @@ public static DateTime DateTime2FromParts( /// The hour portion of the time zone offset (-14 through +14). /// The minute portion of the time zone offset (0 or 30). /// The precision of the datetimeoffset value (0 through 7). - /// New instance of the structure to the specified year, month, day, hour, minute, second, fractions, hourOffset, minuteOffset and precision. + /// + /// New instance of the structure to the specified year, month, day, hour, minute, second, fractions, + /// hourOffset, minuteOffset and precision. + /// public static DateTimeOffset DateTimeOffsetFromParts( [CanBeNull] this DbFunctions _, int year, diff --git a/src/EFCore.SqlServer/Extensions/SqlServerEntityTypeBuilderExtensions.cs b/src/EFCore.SqlServer/Extensions/SqlServerEntityTypeBuilderExtensions.cs index ed8a7c9a3de..1ed6a484690 100644 --- a/src/EFCore.SqlServer/Extensions/SqlServerEntityTypeBuilderExtensions.cs +++ b/src/EFCore.SqlServer/Extensions/SqlServerEntityTypeBuilderExtensions.cs @@ -21,7 +21,8 @@ public static class SqlServerEntityTypeBuilderExtensions /// A value indicating whether the table is memory-optimized. /// The same builder instance so that multiple calls can be chained. public static EntityTypeBuilder IsMemoryOptimized( - [NotNull] this EntityTypeBuilder entityTypeBuilder, bool memoryOptimized = true) + [NotNull] this EntityTypeBuilder entityTypeBuilder, + bool memoryOptimized = true) { Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); @@ -38,7 +39,8 @@ public static EntityTypeBuilder IsMemoryOptimized( /// A value indicating whether the table is memory-optimized. /// The same builder instance so that multiple calls can be chained. public static EntityTypeBuilder IsMemoryOptimized( - [NotNull] this EntityTypeBuilder entityTypeBuilder, bool memoryOptimized = true) + [NotNull] this EntityTypeBuilder entityTypeBuilder, + bool memoryOptimized = true) where TEntity : class => (EntityTypeBuilder)IsMemoryOptimized((EntityTypeBuilder)entityTypeBuilder, memoryOptimized); @@ -49,7 +51,8 @@ public static EntityTypeBuilder IsMemoryOptimized( /// A value indicating whether the table is memory-optimized. /// The same builder instance so that multiple calls can be chained. public static OwnedNavigationBuilder IsMemoryOptimized( - [NotNull] this OwnedNavigationBuilder collectionOwnershipBuilder, bool memoryOptimized = true) + [NotNull] this OwnedNavigationBuilder collectionOwnershipBuilder, + bool memoryOptimized = true) { Check.NotNull(collectionOwnershipBuilder, nameof(collectionOwnershipBuilder)); @@ -67,7 +70,8 @@ public static OwnedNavigationBuilder IsMemoryOptimized( /// A value indicating whether the table is memory-optimized. /// The same builder instance so that multiple calls can be chained. public static OwnedNavigationBuilder IsMemoryOptimized( - [NotNull] this OwnedNavigationBuilder collectionOwnershipBuilder, bool memoryOptimized = true) + [NotNull] this OwnedNavigationBuilder collectionOwnershipBuilder, + bool memoryOptimized = true) where TEntity : class where TRelatedEntity : class => (OwnedNavigationBuilder)IsMemoryOptimized( diff --git a/src/EFCore.SqlServer/Extensions/SqlServerEntityTypeExtensions.cs b/src/EFCore.SqlServer/Extensions/SqlServerEntityTypeExtensions.cs index 1c272408f0d..709d12e08f8 100644 --- a/src/EFCore.SqlServer/Extensions/SqlServerEntityTypeExtensions.cs +++ b/src/EFCore.SqlServer/Extensions/SqlServerEntityTypeExtensions.cs @@ -37,7 +37,9 @@ public static void SetIsMemoryOptimized([NotNull] this IMutableEntityType entity /// Indicates whether the configuration was specified using a data annotation. /// The configured value. public static bool? SetIsMemoryOptimized( - [NotNull] this IConventionEntityType entityType, bool? memoryOptimized, bool fromDataAnnotation = false) + [NotNull] this IConventionEntityType entityType, + bool? memoryOptimized, + bool fromDataAnnotation = false) { entityType.SetOrRemoveAnnotation(SqlServerAnnotationNames.MemoryOptimized, memoryOptimized, fromDataAnnotation); diff --git a/src/EFCore.SqlServer/Extensions/SqlServerIndexBuilderExtensions.cs b/src/EFCore.SqlServer/Extensions/SqlServerIndexBuilderExtensions.cs index 0f08c4007ec..4aa267276a8 100644 --- a/src/EFCore.SqlServer/Extensions/SqlServerIndexBuilderExtensions.cs +++ b/src/EFCore.SqlServer/Extensions/SqlServerIndexBuilderExtensions.cs @@ -43,7 +43,8 @@ public static IndexBuilder IsClustered([NotNull] this IndexBuilder indexBuilder, /// A value indicating whether the index is clustered. /// A builder to further configure the index. public static IndexBuilder IsClustered( - [NotNull] this IndexBuilder indexBuilder, bool clustered = true) + [NotNull] this IndexBuilder indexBuilder, + bool clustered = true) => (IndexBuilder)IsClustered((IndexBuilder)indexBuilder, clustered); /// @@ -110,7 +111,8 @@ public static IndexBuilder IncludeProperties([NotNull] this IndexBuilder indexBu /// An array of property names to be used in 'include' clause. /// A builder to further configure the index. public static IndexBuilder IncludeProperties( - [NotNull] this IndexBuilder indexBuilder, [NotNull] params string[] propertyNames) + [NotNull] this IndexBuilder indexBuilder, + [NotNull] params string[] propertyNames) { Check.NotNull(indexBuilder, nameof(indexBuilder)); Check.NotNull(propertyNames, nameof(propertyNames)); @@ -136,7 +138,8 @@ public static IndexBuilder IncludeProperties( /// /// A builder to further configure the index. public static IndexBuilder IncludeProperties( - [NotNull] this IndexBuilder indexBuilder, [NotNull] Expression> includeExpression) + [NotNull] this IndexBuilder indexBuilder, + [NotNull] Expression> includeExpression) { Check.NotNull(indexBuilder, nameof(indexBuilder)); Check.NotNull(includeExpression, nameof(includeExpression)); @@ -214,7 +217,8 @@ public static IndexBuilder IsCreatedOnline([NotNull] this IndexBuilder indexBuil /// A value indicating whether the index is created with online option. /// A builder to further configure the index. public static IndexBuilder IsCreatedOnline( - [NotNull] this IndexBuilder indexBuilder, bool createdOnline = true) + [NotNull] this IndexBuilder indexBuilder, + bool createdOnline = true) => (IndexBuilder)IsCreatedOnline((IndexBuilder)indexBuilder, createdOnline); /// @@ -285,7 +289,8 @@ public static IndexBuilder HasFillFactor([NotNull] this IndexBuilder indexBuilde /// A value indicating whether the index is created with fill factor option. /// A builder to further configure the index. public static IndexBuilder HasFillFactor( - [NotNull] this IndexBuilder indexBuilder, int fillFactor) + [NotNull] this IndexBuilder indexBuilder, + int fillFactor) => (IndexBuilder)HasFillFactor((IndexBuilder)indexBuilder, fillFactor); /// diff --git a/src/EFCore.SqlServer/Extensions/SqlServerIndexExtensions.cs b/src/EFCore.SqlServer/Extensions/SqlServerIndexExtensions.cs index 7935e52ba54..edf075e95a4 100644 --- a/src/EFCore.SqlServer/Extensions/SqlServerIndexExtensions.cs +++ b/src/EFCore.SqlServer/Extensions/SqlServerIndexExtensions.cs @@ -64,7 +64,9 @@ public static void SetIsClustered([NotNull] this IMutableIndex index, bool? valu /// Indicates whether the configuration was specified using a data annotation. /// The configured value. public static bool? SetIsClustered( - [NotNull] this IConventionIndex index, bool? value, bool fromDataAnnotation = false) + [NotNull] this IConventionIndex index, + bool? value, + bool fromDataAnnotation = false) { index.SetOrRemoveAnnotation( SqlServerAnnotationNames.Clustered, @@ -108,7 +110,9 @@ public static void SetIncludeProperties([NotNull] this IMutableIndex index, [Not /// The value to set. /// The configured property names. public static IReadOnlyList SetIncludeProperties( - [NotNull] this IConventionIndex index, [NotNull] IReadOnlyList properties, bool fromDataAnnotation = false) + [NotNull] this IConventionIndex index, + [NotNull] IReadOnlyList properties, + bool fromDataAnnotation = false) { index.SetOrRemoveAnnotation( SqlServerAnnotationNames.Include, @@ -152,7 +156,9 @@ public static void SetIsCreatedOnline([NotNull] this IMutableIndex index, bool? /// Indicates whether the configuration was specified using a data annotation. /// The configured value. public static bool? SetIsCreatedOnline( - [NotNull] this IConventionIndex index, bool? createdOnline, bool fromDataAnnotation = false) + [NotNull] this IConventionIndex index, + bool? createdOnline, + bool fromDataAnnotation = false) { index.SetOrRemoveAnnotation( SqlServerAnnotationNames.CreatedOnline, @@ -176,7 +182,7 @@ public static void SetIsCreatedOnline([NotNull] this IMutableIndex index, bool? /// The index. /// if the index is online. public static int? GetFillFactor([NotNull] this IIndex index) - => (int?)index[SqlServerAnnotationNames.FillFactor]; + => (int?)index[SqlServerAnnotationNames.FillFactor]; /// /// Sets a value indicating whether the index uses the fill factor. diff --git a/src/EFCore.SqlServer/Extensions/SqlServerKeyBuilderExtensions.cs b/src/EFCore.SqlServer/Extensions/SqlServerKeyBuilderExtensions.cs index 30cecb8dcae..ce8b9ad9635 100644 --- a/src/EFCore.SqlServer/Extensions/SqlServerKeyBuilderExtensions.cs +++ b/src/EFCore.SqlServer/Extensions/SqlServerKeyBuilderExtensions.cs @@ -36,7 +36,8 @@ public static KeyBuilder IsClustered([NotNull] this KeyBuilder keyBuilder, bool /// A value indicating whether the key is clustered. /// The same builder instance so that multiple calls can be chained. public static KeyBuilder IsClustered( - [NotNull] this KeyBuilder keyBuilder, bool clustered = true) + [NotNull] this KeyBuilder keyBuilder, + bool clustered = true) => (KeyBuilder)IsClustered((KeyBuilder)keyBuilder, clustered); /// diff --git a/src/EFCore.SqlServer/Extensions/SqlServerMigrationBuilderExtensions.cs b/src/EFCore.SqlServer/Extensions/SqlServerMigrationBuilderExtensions.cs index d57d42773f4..dde5965e112 100644 --- a/src/EFCore.SqlServer/Extensions/SqlServerMigrationBuilderExtensions.cs +++ b/src/EFCore.SqlServer/Extensions/SqlServerMigrationBuilderExtensions.cs @@ -15,14 +15,14 @@ public static class SqlServerMigrationBuilderExtensions { /// /// - /// Returns if the database provider currently in use is the SQL Server provider. + /// Returns if the database provider currently in use is the SQL Server provider. /// /// /// /// The migrationBuilder from the parameters on or /// . /// - /// if SQL Server is being used; otherwise. + /// if SQL Server is being used; otherwise. public static bool IsSqlServer([NotNull] this MigrationBuilder migrationBuilder) => string.Equals( migrationBuilder.ActiveProvider, diff --git a/src/EFCore.SqlServer/Extensions/SqlServerModelBuilderExtensions.cs b/src/EFCore.SqlServer/Extensions/SqlServerModelBuilderExtensions.cs index 678ab790c49..b5b2ee60b84 100644 --- a/src/EFCore.SqlServer/Extensions/SqlServerModelBuilderExtensions.cs +++ b/src/EFCore.SqlServer/Extensions/SqlServerModelBuilderExtensions.cs @@ -136,7 +136,9 @@ public static ModelBuilder UseIdentityColumns( /// otherwise. /// public static IConventionModelBuilder HasIdentityColumnSeed( - [NotNull] this IConventionModelBuilder modelBuilder, int? seed, bool fromDataAnnotation = false) + [NotNull] this IConventionModelBuilder modelBuilder, + int? seed, + bool fromDataAnnotation = false) { if (modelBuilder.CanSetIdentityColumnSeed(seed, fromDataAnnotation)) { @@ -155,7 +157,9 @@ public static IConventionModelBuilder HasIdentityColumnSeed( /// Indicates whether the configuration was specified using a data annotation. /// if the given value can be set as the seed for SQL Server IDENTITY. public static bool CanSetIdentityColumnSeed( - [NotNull] this IConventionModelBuilder modelBuilder, int? seed, bool fromDataAnnotation = false) + [NotNull] this IConventionModelBuilder modelBuilder, + int? seed, + bool fromDataAnnotation = false) { Check.NotNull(modelBuilder, nameof(modelBuilder)); @@ -173,7 +177,9 @@ public static bool CanSetIdentityColumnSeed( /// otherwise. /// public static IConventionModelBuilder HasIdentityColumnIncrement( - [NotNull] this IConventionModelBuilder modelBuilder, int? increment, bool fromDataAnnotation = false) + [NotNull] this IConventionModelBuilder modelBuilder, + int? increment, + bool fromDataAnnotation = false) { if (modelBuilder.CanSetIdentityColumnIncrement(increment, fromDataAnnotation)) { @@ -192,7 +198,9 @@ public static IConventionModelBuilder HasIdentityColumnIncrement( /// Indicates whether the configuration was specified using a data annotation. /// if the given value can be set as the default increment for SQL Server IDENTITY. public static bool CanSetIdentityColumnIncrement( - [NotNull] this IConventionModelBuilder modelBuilder, int? increment, bool fromDataAnnotation = false) + [NotNull] this IConventionModelBuilder modelBuilder, + int? increment, + bool fromDataAnnotation = false) { Check.NotNull(modelBuilder, nameof(modelBuilder)); @@ -290,7 +298,9 @@ public static ModelBuilder HasDatabaseMaxSize([NotNull] this ModelBuilder modelB /// otherwise. /// public static IConventionModelBuilder HasDatabaseMaxSize( - [NotNull] this IConventionModelBuilder modelBuilder, [CanBeNull] string maxSize, bool fromDataAnnotation = false) + [NotNull] this IConventionModelBuilder modelBuilder, + [CanBeNull] string maxSize, + bool fromDataAnnotation = false) { if (modelBuilder.CanSetDatabaseMaxSize(maxSize, fromDataAnnotation)) { @@ -309,7 +319,9 @@ public static IConventionModelBuilder HasDatabaseMaxSize( /// Indicates whether the configuration was specified using a data annotation. /// if the given value can be set as the maximum size of the database. public static bool CanSetDatabaseMaxSize( - [NotNull] this IConventionModelBuilder modelBuilder, [CanBeNull] string maxSize, bool fromDataAnnotation = false) + [NotNull] this IConventionModelBuilder modelBuilder, + [CanBeNull] string maxSize, + bool fromDataAnnotation = false) { Check.NotNull(modelBuilder, nameof(modelBuilder)); @@ -374,7 +386,9 @@ public static ModelBuilder HasServiceTierSql([NotNull] this ModelBuilder modelBu /// otherwise. /// public static IConventionModelBuilder HasServiceTierSql( - [NotNull] this IConventionModelBuilder modelBuilder, [CanBeNull] string serviceTier, bool fromDataAnnotation = false) + [NotNull] this IConventionModelBuilder modelBuilder, + [CanBeNull] string serviceTier, + bool fromDataAnnotation = false) { if (modelBuilder.CanSetServiceTierSql(serviceTier, fromDataAnnotation)) { @@ -393,7 +407,9 @@ public static IConventionModelBuilder HasServiceTierSql( /// Indicates whether the configuration was specified using a data annotation. /// if the given value can be set as the service tier of the database. public static bool CanSetServiceTierSql( - [NotNull] this IConventionModelBuilder modelBuilder, [CanBeNull] string serviceTier, bool fromDataAnnotation = false) + [NotNull] this IConventionModelBuilder modelBuilder, + [CanBeNull] string serviceTier, + bool fromDataAnnotation = false) { Check.NotNull(modelBuilder, nameof(modelBuilder)); @@ -458,7 +474,9 @@ public static ModelBuilder HasPerformanceLevelSql([NotNull] this ModelBuilder mo /// otherwise. /// public static IConventionModelBuilder HasPerformanceLevelSql( - [NotNull] this IConventionModelBuilder modelBuilder, [CanBeNull] string performanceLevel, bool fromDataAnnotation = false) + [NotNull] this IConventionModelBuilder modelBuilder, + [CanBeNull] string performanceLevel, + bool fromDataAnnotation = false) { if (modelBuilder.CanSetPerformanceLevelSql(performanceLevel, fromDataAnnotation)) { @@ -477,7 +495,9 @@ public static IConventionModelBuilder HasPerformanceLevelSql( /// Indicates whether the configuration was specified using a data annotation. /// if the given value can be set as the performance level of the database. public static bool CanSetPerformanceLevelSql( - [NotNull] this IConventionModelBuilder modelBuilder, [CanBeNull] string performanceLevel, bool fromDataAnnotation = false) + [NotNull] this IConventionModelBuilder modelBuilder, + [CanBeNull] string performanceLevel, + bool fromDataAnnotation = false) { Check.NotNull(modelBuilder, nameof(modelBuilder)); diff --git a/src/EFCore.SqlServer/Extensions/SqlServerModelExtensions.cs b/src/EFCore.SqlServer/Extensions/SqlServerModelExtensions.cs index b767fabadcd..17002e7a043 100644 --- a/src/EFCore.SqlServer/Extensions/SqlServerModelExtensions.cs +++ b/src/EFCore.SqlServer/Extensions/SqlServerModelExtensions.cs @@ -48,7 +48,9 @@ public static void SetHiLoSequenceName([NotNull] this IMutableModel model, [CanB /// Indicates whether the configuration was specified using a data annotation. /// The configured value. public static string SetHiLoSequenceName( - [NotNull] this IConventionModel model, [CanBeNull] string name, bool fromDataAnnotation = false) + [NotNull] this IConventionModel model, + [CanBeNull] string name, + bool fromDataAnnotation = false) { Check.NullButNotEmpty(name, nameof(name)); @@ -94,7 +96,9 @@ public static void SetHiLoSequenceSchema([NotNull] this IMutableModel model, [Ca /// Indicates whether the configuration was specified using a data annotation. /// The configured value. public static string SetHiLoSequenceSchema( - [NotNull] this IConventionModel model, [CanBeNull] string value, bool fromDataAnnotation = false) + [NotNull] this IConventionModel model, + [CanBeNull] string value, + bool fromDataAnnotation = false) { Check.NullButNotEmpty(value, nameof(value)); @@ -180,7 +184,9 @@ public static void SetIdentityIncrement([NotNull] this IMutableModel model, int? /// Indicates whether the configuration was specified using a data annotation. /// The configured value. public static int? SetIdentityIncrement( - [NotNull] this IConventionModel model, int? increment, bool fromDataAnnotation = false) + [NotNull] this IConventionModel model, + int? increment, + bool fromDataAnnotation = false) { model.SetOrRemoveAnnotation( SqlServerAnnotationNames.IdentityIncrement, @@ -214,7 +220,8 @@ public static void SetIdentityIncrement([NotNull] this IMutableModel model, int? /// The model. /// The value to set. public static void SetValueGenerationStrategy( - [NotNull] this IMutableModel model, SqlServerValueGenerationStrategy? value) + [NotNull] this IMutableModel model, + SqlServerValueGenerationStrategy? value) => model.SetOrRemoveAnnotation(SqlServerAnnotationNames.ValueGenerationStrategy, value); /// @@ -226,7 +233,9 @@ public static void SetValueGenerationStrategy( /// Indicates whether the configuration was specified using a data annotation. /// The configured value. public static SqlServerValueGenerationStrategy? SetValueGenerationStrategy( - [NotNull] this IConventionModel model, SqlServerValueGenerationStrategy? value, bool fromDataAnnotation = false) + [NotNull] this IConventionModel model, + SqlServerValueGenerationStrategy? value, + bool fromDataAnnotation = false) { model.SetOrRemoveAnnotation(SqlServerAnnotationNames.ValueGenerationStrategy, value, fromDataAnnotation); @@ -265,7 +274,9 @@ public static void SetDatabaseMaxSize([NotNull] this IMutableModel model, [CanBe /// Indicates whether the configuration was specified using a data annotation. /// The configured value. public static string SetDatabaseMaxSize( - [NotNull] this IConventionModel model, [CanBeNull] string value, bool fromDataAnnotation = false) + [NotNull] this IConventionModel model, + [CanBeNull] string value, + bool fromDataAnnotation = false) { model.SetOrRemoveAnnotation(SqlServerAnnotationNames.MaxDatabaseSize, value, fromDataAnnotation); @@ -304,7 +315,9 @@ public static void SetServiceTierSql([NotNull] this IMutableModel model, [CanBeN /// Indicates whether the configuration was specified using a data annotation. /// The configured value. public static string SetServiceTierSql( - [NotNull] this IConventionModel model, [CanBeNull] string value, bool fromDataAnnotation = false) + [NotNull] this IConventionModel model, + [CanBeNull] string value, + bool fromDataAnnotation = false) { model.SetOrRemoveAnnotation(SqlServerAnnotationNames.ServiceTierSql, value, fromDataAnnotation); @@ -343,7 +356,9 @@ public static void SetPerformanceLevelSql([NotNull] this IMutableModel model, [C /// Indicates whether the configuration was specified using a data annotation. /// The configured value. public static string SetPerformanceLevelSql( - [NotNull] this IConventionModel model, [CanBeNull] string value, bool fromDataAnnotation = false) + [NotNull] this IConventionModel model, + [CanBeNull] string value, + bool fromDataAnnotation = false) { model.SetOrRemoveAnnotation(SqlServerAnnotationNames.PerformanceLevelSql, value, fromDataAnnotation); diff --git a/src/EFCore.SqlServer/Extensions/SqlServerPropertyBuilderExtensions.cs b/src/EFCore.SqlServer/Extensions/SqlServerPropertyBuilderExtensions.cs index bd7d50ae30a..87b10a7cf72 100644 --- a/src/EFCore.SqlServer/Extensions/SqlServerPropertyBuilderExtensions.cs +++ b/src/EFCore.SqlServer/Extensions/SqlServerPropertyBuilderExtensions.cs @@ -168,7 +168,9 @@ public static PropertyBuilder UseIdentityColumn( /// otherwise. /// public static IConventionPropertyBuilder HasIdentityColumnSeed( - [NotNull] this IConventionPropertyBuilder propertyBuilder, int? seed, bool fromDataAnnotation = false) + [NotNull] this IConventionPropertyBuilder propertyBuilder, + int? seed, + bool fromDataAnnotation = false) { if (propertyBuilder.CanSetIdentityColumnSeed(seed, fromDataAnnotation)) { @@ -187,7 +189,9 @@ public static IConventionPropertyBuilder HasIdentityColumnSeed( /// Indicates whether the configuration was specified using a data annotation. /// if the given value can be set as the seed for SQL Server IDENTITY. public static bool CanSetIdentityColumnSeed( - [NotNull] this IConventionPropertyBuilder propertyBuilder, int? seed, bool fromDataAnnotation = false) + [NotNull] this IConventionPropertyBuilder propertyBuilder, + int? seed, + bool fromDataAnnotation = false) { Check.NotNull(propertyBuilder, nameof(propertyBuilder)); @@ -205,7 +209,9 @@ public static bool CanSetIdentityColumnSeed( /// otherwise. /// public static IConventionPropertyBuilder HasIdentityColumnIncrement( - [NotNull] this IConventionPropertyBuilder propertyBuilder, int? increment, bool fromDataAnnotation = false) + [NotNull] this IConventionPropertyBuilder propertyBuilder, + int? increment, + bool fromDataAnnotation = false) { if (propertyBuilder.CanSetIdentityColumnIncrement(increment, fromDataAnnotation)) { @@ -224,7 +230,9 @@ public static IConventionPropertyBuilder HasIdentityColumnIncrement( /// Indicates whether the configuration was specified using a data annotation. /// if the given value can be set as the default increment for SQL Server IDENTITY. public static bool CanSetIdentityColumnIncrement( - [NotNull] this IConventionPropertyBuilder propertyBuilder, int? increment, bool fromDataAnnotation = false) + [NotNull] this IConventionPropertyBuilder propertyBuilder, + int? increment, + bool fromDataAnnotation = false) { Check.NotNull(propertyBuilder, nameof(propertyBuilder)); diff --git a/src/EFCore.SqlServer/Extensions/SqlServerPropertyExtensions.cs b/src/EFCore.SqlServer/Extensions/SqlServerPropertyExtensions.cs index 14ef5a2bdac..5a51c533096 100644 --- a/src/EFCore.SqlServer/Extensions/SqlServerPropertyExtensions.cs +++ b/src/EFCore.SqlServer/Extensions/SqlServerPropertyExtensions.cs @@ -56,7 +56,9 @@ public static void SetHiLoSequenceName([NotNull] this IMutableProperty property, /// Indicates whether the configuration was specified using a data annotation. /// The configured value. public static string SetHiLoSequenceName( - [NotNull] this IConventionProperty property, [CanBeNull] string name, bool fromDataAnnotation = false) + [NotNull] this IConventionProperty property, + [CanBeNull] string name, + bool fromDataAnnotation = false) { property.SetOrRemoveAnnotation( SqlServerAnnotationNames.HiLoSequenceName, @@ -112,7 +114,9 @@ public static void SetHiLoSequenceSchema([NotNull] this IMutableProperty propert /// Indicates whether the configuration was specified using a data annotation. /// The configured value. public static string SetHiLoSequenceSchema( - [NotNull] this IConventionProperty property, [CanBeNull] string schema, bool fromDataAnnotation = false) + [NotNull] this IConventionProperty property, + [CanBeNull] string schema, + bool fromDataAnnotation = false) { property.SetOrRemoveAnnotation( SqlServerAnnotationNames.HiLoSequenceSchema, @@ -193,7 +197,9 @@ public static void SetIdentitySeed([NotNull] this IMutableProperty property, int /// Indicates whether the configuration was specified using a data annotation. /// The configured value. public static int? SetIdentitySeed( - [NotNull] this IConventionProperty property, int? seed, bool fromDataAnnotation = false) + [NotNull] this IConventionProperty property, + int? seed, + bool fromDataAnnotation = false) { property.SetOrRemoveAnnotation( SqlServerAnnotationNames.IdentitySeed, @@ -257,7 +263,9 @@ public static void SetIdentityIncrement([NotNull] this IMutableProperty property /// Indicates whether the configuration was specified using a data annotation. /// The configured value. public static int? SetIdentityIncrement( - [NotNull] this IConventionProperty property, int? increment, bool fromDataAnnotation = false) + [NotNull] this IConventionProperty property, + int? increment, + bool fromDataAnnotation = false) { property.SetOrRemoveAnnotation( SqlServerAnnotationNames.IdentityIncrement, @@ -369,7 +377,8 @@ private static SqlServerValueGenerationStrategy GetDefaultValueGenerationStrateg /// The property. /// The strategy to use. public static void SetValueGenerationStrategy( - [NotNull] this IMutableProperty property, SqlServerValueGenerationStrategy? value) + [NotNull] this IMutableProperty property, + SqlServerValueGenerationStrategy? value) { CheckValueGenerationStrategy(property, value); @@ -384,7 +393,9 @@ public static void SetValueGenerationStrategy( /// Indicates whether the configuration was specified using a data annotation. /// The configured value. public static SqlServerValueGenerationStrategy? SetValueGenerationStrategy( - [NotNull] this IConventionProperty property, SqlServerValueGenerationStrategy? value, bool fromDataAnnotation = false) + [NotNull] this IConventionProperty property, + SqlServerValueGenerationStrategy? value, + bool fromDataAnnotation = false) { CheckValueGenerationStrategy(property, value); diff --git a/src/EFCore.SqlServer/Infrastructure/Internal/SqlServerOptionsExtension.cs b/src/EFCore.SqlServer/Infrastructure/Internal/SqlServerOptionsExtension.cs index b38942a9615..9036da4eee0 100644 --- a/src/EFCore.SqlServer/Infrastructure/Internal/SqlServerOptionsExtension.cs +++ b/src/EFCore.SqlServer/Infrastructure/Internal/SqlServerOptionsExtension.cs @@ -81,7 +81,8 @@ public ExtensionInfo(IDbContextOptionsExtension extension) private new SqlServerOptionsExtension Extension => (SqlServerOptionsExtension)base.Extension; - public override bool IsDatabaseProvider => true; + public override bool IsDatabaseProvider + => true; public override string LogFragment { diff --git a/src/EFCore.SqlServer/Internal/SqlServerLoggerExtensions.cs b/src/EFCore.SqlServer/Internal/SqlServerLoggerExtensions.cs index a7c1f63adaa..1b3fa22ed4e 100644 --- a/src/EFCore.SqlServer/Internal/SqlServerLoggerExtensions.cs +++ b/src/EFCore.SqlServer/Internal/SqlServerLoggerExtensions.cs @@ -143,7 +143,8 @@ public static void ConflictingValueGenerationStrategiesWarning( if (diagnostics.ShouldLog(definition)) { - definition.Log(diagnostics, sqlServerValueGenerationStrategy.ToString(), otherValueGenerationStrategy, + definition.Log( + diagnostics, sqlServerValueGenerationStrategy.ToString(), otherValueGenerationStrategy, property.Name, property.DeclaringEntityType.DisplayName()); } diff --git a/src/EFCore.SqlServer/Internal/SqlServerModelValidator.cs b/src/EFCore.SqlServer/Internal/SqlServerModelValidator.cs index 80fa1831ea4..d5cce0f766c 100644 --- a/src/EFCore.SqlServer/Internal/SqlServerModelValidator.cs +++ b/src/EFCore.SqlServer/Internal/SqlServerModelValidator.cs @@ -67,11 +67,13 @@ public override void Validate(IModel model, IDiagnosticsLogger protected virtual void ValidateDecimalColumns( - [NotNull] IModel model, [NotNull] IDiagnosticsLogger logger) + [NotNull] IModel model, + [NotNull] IDiagnosticsLogger logger) { foreach (IConventionProperty property in model.GetEntityTypes() .SelectMany(t => t.GetDeclaredProperties()) - .Where(p => p.ClrType.UnwrapNullableType() == typeof(decimal) + .Where( + p => p.ClrType.UnwrapNullableType() == typeof(decimal) && !p.IsForeignKey())) { var valueConverterConfigurationSource = property.GetValueConverterConfigurationSource(); @@ -84,9 +86,9 @@ protected virtual void ValidateDecimalColumns( var columnTypeConfigurationSource = property.GetColumnTypeConfigurationSource(); if (((columnTypeConfigurationSource == null - && ConfigurationSource.Convention.Overrides(property.GetTypeMappingConfigurationSource())) - || (columnTypeConfigurationSource != null - && ConfigurationSource.Convention.Overrides(columnTypeConfigurationSource))) + && ConfigurationSource.Convention.Overrides(property.GetTypeMappingConfigurationSource())) + || (columnTypeConfigurationSource != null + && ConfigurationSource.Convention.Overrides(columnTypeConfigurationSource))) && (ConfigurationSource.Convention.Overrides(property.GetPrecisionConfigurationSource()) || ConfigurationSource.Convention.Overrides(property.GetScaleConfigurationSource()))) { @@ -107,12 +109,14 @@ protected virtual void ValidateDecimalColumns( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected virtual void ValidateByteIdentityMapping( - [NotNull] IModel model, [NotNull] IDiagnosticsLogger logger) + [NotNull] IModel model, + [NotNull] IDiagnosticsLogger logger) { foreach (var entityType in model.GetEntityTypes()) { foreach (var property in entityType.GetDeclaredProperties() - .Where(p => p.ClrType.UnwrapNullableType() == typeof(byte) + .Where( + p => p.ClrType.UnwrapNullableType() == typeof(byte) && p.GetValueGenerationStrategy() == SqlServerValueGenerationStrategy.IdentityColumn)) { logger.ByteIdentityColumnWarning(property); @@ -127,12 +131,14 @@ protected virtual void ValidateByteIdentityMapping( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected virtual void ValidateNonKeyValueGeneration( - [NotNull] IModel model, [NotNull] IDiagnosticsLogger logger) + [NotNull] IModel model, + [NotNull] IDiagnosticsLogger logger) { foreach (var entityType in model.GetEntityTypes()) { foreach (var property in entityType.GetDeclaredProperties() - .Where(p => p.GetValueGenerationStrategy() == SqlServerValueGenerationStrategy.SequenceHiLo + .Where( + p => p.GetValueGenerationStrategy() == SqlServerValueGenerationStrategy.SequenceHiLo && ((IConventionProperty)p).GetValueGenerationStrategyConfigurationSource() != null && !p.IsKey() && p.ValueGenerated != ValueGenerated.Never @@ -152,7 +158,8 @@ protected virtual void ValidateNonKeyValueGeneration( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected virtual void ValidateIndexIncludeProperties( - [NotNull] IModel model, [NotNull] IDiagnosticsLogger logger) + [NotNull] IModel model, + [NotNull] IDiagnosticsLogger logger) { foreach (var index in model.GetEntityTypes().SelectMany(t => t.GetDeclaredIndexes())) { diff --git a/src/EFCore.SqlServer/Metadata/Conventions/SqlServerConventionSetBuilder.cs b/src/EFCore.SqlServer/Metadata/Conventions/SqlServerConventionSetBuilder.cs index dad85957c3c..9534d5ba9b3 100644 --- a/src/EFCore.SqlServer/Metadata/Conventions/SqlServerConventionSetBuilder.cs +++ b/src/EFCore.SqlServer/Metadata/Conventions/SqlServerConventionSetBuilder.cs @@ -97,7 +97,8 @@ public override ConventionSet CreateConventionSet() conventionSet.ModelFinalizingConventions.Add(valueGenerationStrategyConvention); ReplaceConvention(conventionSet.ModelFinalizingConventions, storeGenerationConvention); - ReplaceConvention(conventionSet.ModelFinalizingConventions, + ReplaceConvention( + conventionSet.ModelFinalizingConventions, (SharedTableConvention)new SqlServerSharedTableConvention(Dependencies, RelationalDependencies)); conventionSet.ModelFinalizingConventions.Add(new SqlServerDbFunctionConvention(Dependencies, RelationalDependencies)); diff --git a/src/EFCore.SqlServer/Metadata/Conventions/SqlServerDbFunctionConvention.cs b/src/EFCore.SqlServer/Metadata/Conventions/SqlServerDbFunctionConvention.cs index db25c52e2d3..75b021c82ee 100644 --- a/src/EFCore.SqlServer/Metadata/Conventions/SqlServerDbFunctionConvention.cs +++ b/src/EFCore.SqlServer/Metadata/Conventions/SqlServerDbFunctionConvention.cs @@ -10,8 +10,8 @@ namespace Microsoft.EntityFrameworkCore.Metadata.Conventions { /// - /// A convention that ensures that is populated for database functions which - /// have flag set to . + /// A convention that ensures that is populated for database functions which + /// have flag set to . /// public class SqlServerDbFunctionConvention : IModelFinalizingConvention { @@ -36,7 +36,9 @@ public SqlServerDbFunctionConvention( protected virtual ProviderConventionSetBuilderDependencies Dependencies { get; } /// - public virtual void ProcessModelFinalizing(IConventionModelBuilder modelBuilder, IConventionContext context) + public virtual void ProcessModelFinalizing( + IConventionModelBuilder modelBuilder, + IConventionContext context) { foreach (var dbFunction in modelBuilder.Metadata.GetDbFunctions()) { diff --git a/src/EFCore.SqlServer/Metadata/Conventions/SqlServerIndexConvention.cs b/src/EFCore.SqlServer/Metadata/Conventions/SqlServerIndexConvention.cs index 98fec9a9033..e87910440d2 100644 --- a/src/EFCore.SqlServer/Metadata/Conventions/SqlServerIndexConvention.cs +++ b/src/EFCore.SqlServer/Metadata/Conventions/SqlServerIndexConvention.cs @@ -75,7 +75,8 @@ public virtual void ProcessEntityTypeBaseTypeChanged( /// The builder for the index. /// Additional information associated with convention execution. public virtual void ProcessIndexAdded( - IConventionIndexBuilder indexBuilder, IConventionContext context) + IConventionIndexBuilder indexBuilder, + IConventionContext context) => SetIndexFilter(indexBuilder); /// @@ -84,7 +85,8 @@ public virtual void ProcessIndexAdded( /// The builder for the index. /// Additional information associated with convention execution. public virtual void ProcessIndexUniquenessChanged( - IConventionIndexBuilder indexBuilder, IConventionContext context) + IConventionIndexBuilder indexBuilder, + IConventionContext context) => SetIndexFilter(indexBuilder); /// diff --git a/src/EFCore.SqlServer/Metadata/Conventions/SqlServerOnDeleteConvention.cs b/src/EFCore.SqlServer/Metadata/Conventions/SqlServerOnDeleteConvention.cs index ad5b16bf42d..a2705ad7acd 100644 --- a/src/EFCore.SqlServer/Metadata/Conventions/SqlServerOnDeleteConvention.cs +++ b/src/EFCore.SqlServer/Metadata/Conventions/SqlServerOnDeleteConvention.cs @@ -58,8 +58,9 @@ protected override DeleteBehavior GetTargetDeleteBehavior(IConventionForeignKey return deleteBehavior; } - if (selfReferencingSkipNavigation == selfReferencingSkipNavigation.DeclaringEntityType.GetDeclaredSkipNavigations() - .First(s => s == selfReferencingSkipNavigation || s == selfReferencingSkipNavigation.Inverse)) + if (selfReferencingSkipNavigation + == selfReferencingSkipNavigation.DeclaringEntityType.GetDeclaredSkipNavigations() + .First(s => s == selfReferencingSkipNavigation || s == selfReferencingSkipNavigation.Inverse)) { selfReferencingSkipNavigation.Inverse.ForeignKey?.Builder.OnDelete( GetTargetDeleteBehavior(selfReferencingSkipNavigation.Inverse.ForeignKey)); diff --git a/src/EFCore.SqlServer/Metadata/Conventions/SqlServerSharedTableConvention.cs b/src/EFCore.SqlServer/Metadata/Conventions/SqlServerSharedTableConvention.cs index 329bd75cdb5..a30fb790f23 100644 --- a/src/EFCore.SqlServer/Metadata/Conventions/SqlServerSharedTableConvention.cs +++ b/src/EFCore.SqlServer/Metadata/Conventions/SqlServerSharedTableConvention.cs @@ -1,14 +1,9 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System.Linq; -using System.Text; using JetBrains.Annotations; -using Microsoft.EntityFrameworkCore.Metadata.Builders; using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata.Internal; -using Microsoft.EntityFrameworkCore.SqlServer.Metadata.Internal; -using Microsoft.EntityFrameworkCore.Storage; // ReSharper disable once CheckNamespace namespace Microsoft.EntityFrameworkCore.Metadata.Conventions diff --git a/src/EFCore.SqlServer/Metadata/Conventions/SqlServerStoreGenerationConvention.cs b/src/EFCore.SqlServer/Metadata/Conventions/SqlServerStoreGenerationConvention.cs index f99cd49b5d2..ab31b0c58c5 100644 --- a/src/EFCore.SqlServer/Metadata/Conventions/SqlServerStoreGenerationConvention.cs +++ b/src/EFCore.SqlServer/Metadata/Conventions/SqlServerStoreGenerationConvention.cs @@ -96,7 +96,7 @@ public override void ProcessPropertyAnnotationChanged( base.ProcessPropertyAnnotationChanged(propertyBuilder, name, annotation, oldAnnotation, context); } - /// + /// protected override void Validate(IConventionProperty property, in StoreObjectIdentifier storeObject) { if (property.GetValueGenerationStrategyConfigurationSource() != null) diff --git a/src/EFCore.SqlServer/Metadata/Conventions/SqlServerValueGenerationStrategyConvention.cs b/src/EFCore.SqlServer/Metadata/Conventions/SqlServerValueGenerationStrategyConvention.cs index abb2817fa48..517062de367 100644 --- a/src/EFCore.SqlServer/Metadata/Conventions/SqlServerValueGenerationStrategyConvention.cs +++ b/src/EFCore.SqlServer/Metadata/Conventions/SqlServerValueGenerationStrategyConvention.cs @@ -31,14 +31,16 @@ public SqlServerValueGenerationStrategyConvention( /// The builder for the model. /// Additional information associated with convention execution. public virtual void ProcessModelInitialized( - IConventionModelBuilder modelBuilder, IConventionContext context) + IConventionModelBuilder modelBuilder, + IConventionContext context) { modelBuilder.HasValueGenerationStrategy(SqlServerValueGenerationStrategy.IdentityColumn); } /// public virtual void ProcessModelFinalizing( - IConventionModelBuilder modelBuilder, IConventionContext context) + IConventionModelBuilder modelBuilder, + IConventionContext context) { foreach (var entityType in modelBuilder.Metadata.GetEntityTypes()) { diff --git a/src/EFCore.SqlServer/Metadata/Internal/SqlServerAnnotationProvider.cs b/src/EFCore.SqlServer/Metadata/Internal/SqlServerAnnotationProvider.cs index c13fbcbb96b..e90ed375a16 100644 --- a/src/EFCore.SqlServer/Metadata/Internal/SqlServerAnnotationProvider.cs +++ b/src/EFCore.SqlServer/Metadata/Internal/SqlServerAnnotationProvider.cs @@ -149,8 +149,9 @@ public override IEnumerable For(ITableIndex index) if (includeProperties != null) { var includeColumns = (IReadOnlyList)includeProperties - .Select(p => modelIndex.DeclaringEntityType.FindProperty(p) - .GetColumnName(StoreObjectIdentifier.Table(table.Name, table.Schema))) + .Select( + p => modelIndex.DeclaringEntityType.FindProperty(p) + .GetColumnName(StoreObjectIdentifier.Table(table.Name, table.Schema))) .ToArray(); yield return new Annotation( @@ -184,11 +185,13 @@ public override IEnumerable For(ITableIndex index) public override IEnumerable For(IColumn column) { var table = StoreObjectIdentifier.Table(column.Table.Name, column.Table.Schema); - var property = column.PropertyMappings.Where(m => - m.TableMapping.IsSharedTablePrincipal && m.TableMapping.EntityType == m.Property.DeclaringEntityType) + var property = column.PropertyMappings.Where( + m => + m.TableMapping.IsSharedTablePrincipal && m.TableMapping.EntityType == m.Property.DeclaringEntityType) .Select(m => m.Property) - .FirstOrDefault(p => p.GetValueGenerationStrategy(table) - == SqlServerValueGenerationStrategy.IdentityColumn); + .FirstOrDefault( + p => p.GetValueGenerationStrategy(table) + == SqlServerValueGenerationStrategy.IdentityColumn); if (property != null) { var seed = property.GetIdentitySeed(table); diff --git a/src/EFCore.SqlServer/Metadata/Internal/SqlServerIndexExtensions.cs b/src/EFCore.SqlServer/Metadata/Internal/SqlServerIndexExtensions.cs index 0bb6170236c..f23f05edb1e 100644 --- a/src/EFCore.SqlServer/Metadata/Internal/SqlServerIndexExtensions.cs +++ b/src/EFCore.SqlServer/Metadata/Internal/SqlServerIndexExtensions.cs @@ -107,7 +107,7 @@ public static bool AreCompatibleForSqlServer( static bool SameColumnNames(IIndex index, IIndex duplicateIndex, StoreObjectIdentifier storeObject) => index.GetIncludeProperties().Select( - p => index.DeclaringEntityType.FindProperty(p).GetColumnName(storeObject)) + p => index.DeclaringEntityType.FindProperty(p).GetColumnName(storeObject)) .SequenceEqual( duplicateIndex.GetIncludeProperties().Select( p => duplicateIndex.DeclaringEntityType.FindProperty(p) @@ -118,9 +118,11 @@ private static string FormatInclude(IIndex index, StoreObjectIdentifier storeObj => index.GetIncludeProperties() == null ? "{}" : "{'" - + string.Join("', '", - index.GetIncludeProperties().Select(p => index.DeclaringEntityType.FindProperty(p) + + string.Join( + "', '", + index.GetIncludeProperties().Select( + p => index.DeclaringEntityType.FindProperty(p) ?.GetColumnName(storeObject))) - + "'}"; + + "'}"; } } diff --git a/src/EFCore.SqlServer/Metadata/SqlServerValueGenerationStrategy.cs b/src/EFCore.SqlServer/Metadata/SqlServerValueGenerationStrategy.cs index 1c6fd5df4a5..610e8fac7b9 100644 --- a/src/EFCore.SqlServer/Metadata/SqlServerValueGenerationStrategy.cs +++ b/src/EFCore.SqlServer/Metadata/SqlServerValueGenerationStrategy.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // ReSharper disable once CheckNamespace + namespace Microsoft.EntityFrameworkCore.Metadata { /// diff --git a/src/EFCore.SqlServer/Migrations/SqlServerMigrationsSqlGenerator.cs b/src/EFCore.SqlServer/Migrations/SqlServerMigrationsSqlGenerator.cs index 76f914404b0..29d19f31786 100644 --- a/src/EFCore.SqlServer/Migrations/SqlServerMigrationsSqlGenerator.cs +++ b/src/EFCore.SqlServer/Migrations/SqlServerMigrationsSqlGenerator.cs @@ -57,7 +57,10 @@ public SqlServerMigrationsSqlGenerator( /// The target model which may be if the operations exist without a model. /// The options to use when generating commands. /// The list of commands to be executed or scripted. - public override IReadOnlyList Generate(IReadOnlyList operations, IModel model = null, MigrationsSqlGenerationOptions options = MigrationsSqlGenerationOptions.Default) + public override IReadOnlyList Generate( + IReadOnlyList operations, + IModel model = null, + MigrationsSqlGenerationOptions options = MigrationsSqlGenerationOptions.Default) { _operations = operations; try @@ -1509,7 +1512,8 @@ protected override void ComputedColumnDefinition( protected virtual void Rename( [NotNull] string name, [NotNull] string newName, - [NotNull] MigrationCommandListBuilder builder) => Rename(name, newName, /*type:*/ null, builder); + [NotNull] MigrationCommandListBuilder builder) + => Rename(name, newName, /*type:*/ null, builder); /// /// Generates a rename. @@ -1883,7 +1887,8 @@ protected virtual void AddDescription( builder.AppendLine(Dependencies.SqlGenerationHelper.StatementTerminator); - string Literal(string s) => stringTypeMapping.GenerateSqlLiteral(s); + string Literal(string s) + => stringTypeMapping.GenerateSqlLiteral(s); } /// @@ -1946,7 +1951,8 @@ protected virtual void DropDescription( builder.AppendLine(Dependencies.SqlGenerationHelper.StatementTerminator); - string Literal(string s) => stringTypeMapping.GenerateSqlLiteral(s); + string Literal(string s) + => stringTypeMapping.GenerateSqlLiteral(s); } /// @@ -1954,7 +1960,7 @@ protected virtual void DropDescription( /// Migrations. /// /// The target model. - /// if a filter should be generated. + /// if a filter should be generated. protected virtual bool UseLegacyIndexFilters([CanBeNull] IModel model) => !TryGetVersion(model, out var version) || VersionComparer.Compare(version, "2.0.0") < 0; diff --git a/src/EFCore.SqlServer/Query/Internal/SearchConditionConvertingExpressionVisitor.cs b/src/EFCore.SqlServer/Query/Internal/SearchConditionConvertingExpressionVisitor.cs index f6258b0f3c4..e3547f2ba5e 100644 --- a/src/EFCore.SqlServer/Query/Internal/SearchConditionConvertingExpressionVisitor.cs +++ b/src/EFCore.SqlServer/Query/Internal/SearchConditionConvertingExpressionVisitor.cs @@ -62,14 +62,14 @@ private SqlExpression ConvertToValue(SqlExpression sqlExpression, bool condition private SqlExpression BuildCompareToExpression(SqlExpression sqlExpression) => sqlExpression is SqlConstantExpression sqlConstantExpression && sqlConstantExpression.Value is bool boolValue - ? _sqlExpressionFactory.Equal( - boolValue - ? _sqlExpressionFactory.Constant(1) - : _sqlExpressionFactory.Constant(0), - _sqlExpressionFactory.Constant(1)) - : _sqlExpressionFactory.Equal( - sqlExpression, - _sqlExpressionFactory.Constant(true)); + ? _sqlExpressionFactory.Equal( + boolValue + ? _sqlExpressionFactory.Constant(1) + : _sqlExpressionFactory.Constant(0), + _sqlExpressionFactory.Constant(1)) + : _sqlExpressionFactory.Equal( + sqlExpression, + _sqlExpressionFactory.Constant(true)); // !(a == b) -> (a != b) // !(a != b) -> (a == b) @@ -79,14 +79,14 @@ private SqlExpression SimplifyNegatedBinary(SqlExpression sqlExpression) && sqlUnaryExpression.Type == typeof(bool) && sqlUnaryExpression.Operand is SqlBinaryExpression sqlBinaryOperand && (sqlBinaryOperand.OperatorType == ExpressionType.Equal || sqlBinaryOperand.OperatorType == ExpressionType.NotEqual) - ? _sqlExpressionFactory.MakeBinary( - sqlBinaryOperand.OperatorType == ExpressionType.Equal - ? ExpressionType.NotEqual - : ExpressionType.Equal, - sqlBinaryOperand.Left, - sqlBinaryOperand.Right, - sqlBinaryOperand.TypeMapping) - : sqlExpression; + ? _sqlExpressionFactory.MakeBinary( + sqlBinaryOperand.OperatorType == ExpressionType.Equal + ? ExpressionType.NotEqual + : ExpressionType.Equal, + sqlBinaryOperand.Left, + sqlBinaryOperand.Right, + sqlBinaryOperand.TypeMapping) + : sqlExpression; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -369,7 +369,7 @@ protected override Expression VisitSqlUnary(SqlUnaryExpression sqlUnaryExpressio switch (sqlUnaryExpression.OperatorType) { case ExpressionType.Not - when sqlUnaryExpression.Type == typeof(bool): + when sqlUnaryExpression.Type == typeof(bool): { _isSearchCondition = true; resultCondition = true; diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerByteArrayMethodTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerByteArrayMethodTranslator.cs index fb568dc6758..36d9cd2c738 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerByteArrayMethodTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerByteArrayMethodTranslator.cs @@ -39,7 +39,10 @@ public SqlServerByteArrayMethodTranslator([NotNull] ISqlExpressionFactory sqlExp /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) + SqlExpression instance, + MethodInfo method, + IReadOnlyList arguments, + IDiagnosticsLogger logger) { Check.NotNull(method, nameof(method)); Check.NotNull(arguments, nameof(arguments)); diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerCompiledQueryCacheKeyGenerator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerCompiledQueryCacheKeyGenerator.cs index e82baa3c1c7..a6c99e2248c 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerCompiledQueryCacheKeyGenerator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerCompiledQueryCacheKeyGenerator.cs @@ -54,7 +54,8 @@ public override object GenerateCacheKey(Expression query, bool async) private readonly bool _multipleActiveResultSetsEnabled; public SqlServerCompiledQueryCacheKey( - RelationalCompiledQueryCacheKey relationalCompiledQueryCacheKey, bool multipleActiveResultSetsEnabled) + RelationalCompiledQueryCacheKey relationalCompiledQueryCacheKey, + bool multipleActiveResultSetsEnabled) { _relationalCompiledQueryCacheKey = relationalCompiledQueryCacheKey; _multipleActiveResultSetsEnabled = multipleActiveResultSetsEnabled; @@ -62,13 +63,14 @@ public SqlServerCompiledQueryCacheKey( public override bool Equals(object obj) => obj is SqlServerCompiledQueryCacheKey sqlServerCompiledQueryCacheKey - && Equals(sqlServerCompiledQueryCacheKey); + && Equals(sqlServerCompiledQueryCacheKey); public bool Equals(SqlServerCompiledQueryCacheKey other) => _relationalCompiledQueryCacheKey.Equals(other._relationalCompiledQueryCacheKey) - && _multipleActiveResultSetsEnabled == other._multipleActiveResultSetsEnabled; + && _multipleActiveResultSetsEnabled == other._multipleActiveResultSetsEnabled; - public override int GetHashCode() => HashCode.Combine(_relationalCompiledQueryCacheKey, _multipleActiveResultSetsEnabled); + public override int GetHashCode() + => HashCode.Combine(_relationalCompiledQueryCacheKey, _multipleActiveResultSetsEnabled); } } } diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerConvertTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerConvertTranslator.cs index 134f9e4f80d..5080afd0029 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerConvertTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerConvertTranslator.cs @@ -75,7 +75,10 @@ public SqlServerConvertTranslator([NotNull] ISqlExpressionFactory sqlExpressionF /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) + SqlExpression instance, + MethodInfo method, + IReadOnlyList arguments, + IDiagnosticsLogger logger) { Check.NotNull(method, nameof(method)); Check.NotNull(arguments, nameof(arguments)); diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerDataLengthFunctionTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerDataLengthFunctionTranslator.cs index 55fd42fcfe8..bcbb250a785 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerDataLengthFunctionTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerDataLengthFunctionTranslator.cs @@ -21,7 +21,12 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal /// public class SqlServerDataLengthFunctionTranslator : IMethodCallTranslator { - private static readonly List _longReturningTypes = new List { "nvarchar(max)", "varchar(max)", "varbinary(max)" }; + private static readonly List _longReturningTypes = new List + { + "nvarchar(max)", + "varchar(max)", + "varbinary(max)" + }; private static readonly HashSet _methodInfoDataLengthMapping = new HashSet @@ -29,35 +34,27 @@ private static readonly HashSet _methodInfoDataLengthMapping typeof(SqlServerDbFunctionsExtensions).GetRuntimeMethod( nameof(SqlServerDbFunctionsExtensions.DataLength), new[] { typeof(DbFunctions), typeof(string) }), - typeof(SqlServerDbFunctionsExtensions).GetRuntimeMethod( nameof(SqlServerDbFunctionsExtensions.DataLength), new[] { typeof(DbFunctions), typeof(bool?) }), - typeof(SqlServerDbFunctionsExtensions).GetRuntimeMethod( nameof(SqlServerDbFunctionsExtensions.DataLength), new[] { typeof(DbFunctions), typeof(double?) }), - typeof(SqlServerDbFunctionsExtensions).GetRuntimeMethod( nameof(SqlServerDbFunctionsExtensions.DataLength), new[] { typeof(DbFunctions), typeof(decimal?) }), - typeof(SqlServerDbFunctionsExtensions).GetRuntimeMethod( nameof(SqlServerDbFunctionsExtensions.DataLength), new[] { typeof(DbFunctions), typeof(DateTime?) }), - typeof(SqlServerDbFunctionsExtensions).GetRuntimeMethod( nameof(SqlServerDbFunctionsExtensions.DataLength), new[] { typeof(DbFunctions), typeof(TimeSpan?) }), - typeof(SqlServerDbFunctionsExtensions).GetRuntimeMethod( nameof(SqlServerDbFunctionsExtensions.DataLength), new[] { typeof(DbFunctions), typeof(DateTimeOffset?) }), - typeof(SqlServerDbFunctionsExtensions).GetRuntimeMethod( nameof(SqlServerDbFunctionsExtensions.DataLength), new[] { typeof(DbFunctions), typeof(byte[]) }), - typeof(SqlServerDbFunctionsExtensions).GetRuntimeMethod( nameof(SqlServerDbFunctionsExtensions.DataLength), new[] { typeof(DbFunctions), typeof(Guid?) }) @@ -83,7 +80,10 @@ public SqlServerDataLengthFunctionTranslator([NotNull] ISqlExpressionFactory sql /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) + SqlExpression instance, + MethodInfo method, + IReadOnlyList arguments, + IDiagnosticsLogger logger) { Check.NotNull(method, nameof(method)); Check.NotNull(arguments, nameof(arguments)); diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerDateDiffFunctionsTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerDateDiffFunctionsTranslator.cs index 523608868d7..103cd1c8283 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerDateDiffFunctionsTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerDateDiffFunctionsTranslator.cs @@ -358,7 +358,10 @@ public SqlServerDateDiffFunctionsTranslator( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) + SqlExpression instance, + MethodInfo method, + IReadOnlyList arguments, + IDiagnosticsLogger logger) { Check.NotNull(method, nameof(method)); Check.NotNull(arguments, nameof(arguments)); diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMemberTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMemberTranslator.cs index 353fc8df397..91b9a4bd0c7 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMemberTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMemberTranslator.cs @@ -44,7 +44,8 @@ private static readonly Dictionary _datePartMapping /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public SqlServerDateTimeMemberTranslator( - [NotNull] ISqlExpressionFactory sqlExpressionFactory, [NotNull] IRelationalTypeMappingSource typeMappingSource) + [NotNull] ISqlExpressionFactory sqlExpressionFactory, + [NotNull] IRelationalTypeMappingSource typeMappingSource) { Check.NotNull(sqlExpressionFactory, nameof(sqlExpressionFactory)); Check.NotNull(typeMappingSource, nameof(typeMappingSource)); @@ -60,7 +61,10 @@ public SqlServerDateTimeMemberTranslator( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MemberInfo member, Type returnType, IDiagnosticsLogger logger) + SqlExpression instance, + MemberInfo member, + Type returnType, + IDiagnosticsLogger logger) { Check.NotNull(member, nameof(member)); Check.NotNull(returnType, nameof(returnType)); diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMethodTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMethodTranslator.cs index 5937501ec6c..15ab95f43b1 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMethodTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerDateTimeMethodTranslator.cs @@ -58,7 +58,10 @@ public SqlServerDateTimeMethodTranslator([NotNull] ISqlExpressionFactory sqlExpr /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) + SqlExpression instance, + MethodInfo method, + IReadOnlyList arguments, + IDiagnosticsLogger logger) { Check.NotNull(method, nameof(method)); Check.NotNull(arguments, nameof(arguments)); diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerFromPartsFunctionTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerFromPartsFunctionTranslator.cs index 516c5d041ff..2aa3e481978 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerFromPartsFunctionTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerFromPartsFunctionTranslator.cs @@ -22,29 +22,57 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal public class SqlServerFromPartsFunctionTranslator : IMethodCallTranslator { private static readonly MethodInfo _dateFromPartsMethodInfo = typeof(SqlServerDbFunctionsExtensions) - .GetRuntimeMethod(nameof(SqlServerDbFunctionsExtensions.DateFromParts), + .GetRuntimeMethod( + nameof(SqlServerDbFunctionsExtensions.DateFromParts), new[] { typeof(DbFunctions), typeof(int), typeof(int), typeof(int) }); private static readonly MethodInfo _dateTimeFromPartsMethodInfo = typeof(SqlServerDbFunctionsExtensions) - .GetRuntimeMethod(nameof(SqlServerDbFunctionsExtensions.DateTimeFromParts), + .GetRuntimeMethod( + nameof(SqlServerDbFunctionsExtensions.DateTimeFromParts), new[] { typeof(DbFunctions), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int) }); private static readonly MethodInfo _dateTime2FromPartsMethodInfo = typeof(SqlServerDbFunctionsExtensions) - .GetRuntimeMethod(nameof(SqlServerDbFunctionsExtensions.DateTime2FromParts), - new[] { typeof(DbFunctions), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), - typeof(int), typeof(int), typeof(int) }); + .GetRuntimeMethod( + nameof(SqlServerDbFunctionsExtensions.DateTime2FromParts), + new[] + { + typeof(DbFunctions), + typeof(int), + typeof(int), + typeof(int), + typeof(int), + typeof(int), + typeof(int), + typeof(int), + typeof(int) + }); private static readonly MethodInfo _dateTimeOffsetFromPartsMethodInfo = typeof(SqlServerDbFunctionsExtensions) - .GetRuntimeMethod(nameof(SqlServerDbFunctionsExtensions.DateTimeOffsetFromParts), - new[] { typeof(DbFunctions), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), - typeof(int), typeof(int), typeof(int), typeof(int), typeof(int) }); + .GetRuntimeMethod( + nameof(SqlServerDbFunctionsExtensions.DateTimeOffsetFromParts), + new[] + { + typeof(DbFunctions), + typeof(int), + typeof(int), + typeof(int), + typeof(int), + typeof(int), + typeof(int), + typeof(int), + typeof(int), + typeof(int), + typeof(int) + }); private static readonly MethodInfo _smallDateTimeFromPartsMethodInfo = typeof(SqlServerDbFunctionsExtensions) - .GetRuntimeMethod(nameof(SqlServerDbFunctionsExtensions.SmallDateTimeFromParts), + .GetRuntimeMethod( + nameof(SqlServerDbFunctionsExtensions.SmallDateTimeFromParts), new[] { typeof(DbFunctions), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int) }); private static readonly MethodInfo _timeFromPartsMethodInfo = typeof(SqlServerDbFunctionsExtensions) - .GetRuntimeMethod(nameof(SqlServerDbFunctionsExtensions.TimeFromParts), + .GetRuntimeMethod( + nameof(SqlServerDbFunctionsExtensions.TimeFromParts), new[] { typeof(DbFunctions), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int) }); private static readonly IDictionary _methodFunctionMapping @@ -61,7 +89,6 @@ public class SqlServerFromPartsFunctionTranslator : IMethodCallTranslator private readonly ISqlExpressionFactory _sqlExpressionFactory; private readonly IRelationalTypeMappingSource _typeMappingSource; - /// /// 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 @@ -83,7 +110,10 @@ public SqlServerFromPartsFunctionTranslator( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) + SqlExpression instance, + MethodInfo method, + IReadOnlyList arguments, + IDiagnosticsLogger logger) { Check.NotNull(method, nameof(method)); Check.NotNull(arguments, nameof(arguments)); diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerFullTextSearchFunctionsTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerFullTextSearchFunctionsTranslator.cs index 65f19b5318d..fbf14ecb75d 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerFullTextSearchFunctionsTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerFullTextSearchFunctionsTranslator.cs @@ -74,7 +74,10 @@ public SqlServerFullTextSearchFunctionsTranslator([NotNull] ISqlExpressionFactor /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) + SqlExpression instance, + MethodInfo method, + IReadOnlyList arguments, + IDiagnosticsLogger logger) { Check.NotNull(method, nameof(method)); Check.NotNull(arguments, nameof(arguments)); diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerIsDateFunctionTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerIsDateFunctionTranslator.cs index 80f2c774e22..546b45c25d7 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerIsDateFunctionTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerIsDateFunctionTranslator.cs @@ -40,7 +40,10 @@ public SqlServerIsDateFunctionTranslator([NotNull] ISqlExpressionFactory sqlExpr /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) + SqlExpression instance, + MethodInfo method, + IReadOnlyList arguments, + IDiagnosticsLogger logger) { Check.NotNull(method, nameof(method)); Check.NotNull(arguments, nameof(arguments)); diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerMathTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerMathTranslator.cs index f28065b1eca..6a08804e359 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerMathTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerMathTranslator.cs @@ -90,7 +90,10 @@ public SqlServerMathTranslator([NotNull] ISqlExpressionFactory sqlExpressionFact /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) + SqlExpression instance, + MethodInfo method, + IReadOnlyList arguments, + IDiagnosticsLogger logger) { Check.NotNull(method, nameof(method)); Check.NotNull(arguments, nameof(arguments)); diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerNewGuidTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerNewGuidTranslator.cs index 03d2d598380..0fe1a46aba7 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerNewGuidTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerNewGuidTranslator.cs @@ -41,7 +41,10 @@ public SqlServerNewGuidTranslator([NotNull] ISqlExpressionFactory sqlExpressionF /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) + SqlExpression instance, + MethodInfo method, + IReadOnlyList arguments, + IDiagnosticsLogger logger) { Check.NotNull(method, nameof(method)); Check.NotNull(arguments, nameof(arguments)); diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerObjectToStringTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerObjectToStringTranslator.cs index c347b8cb4be..b08e943eed0 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerObjectToStringTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerObjectToStringTranslator.cs @@ -64,7 +64,10 @@ public SqlServerObjectToStringTranslator([NotNull] ISqlExpressionFactory sqlExpr /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) + SqlExpression instance, + MethodInfo method, + IReadOnlyList arguments, + IDiagnosticsLogger logger) { Check.NotNull(method, nameof(method)); Check.NotNull(arguments, nameof(arguments)); @@ -74,13 +77,13 @@ public virtual SqlExpression Translate( && arguments.Count == 0 && instance != null && _typeMapping.TryGetValue(instance.Type, out var storeType) - ? _sqlExpressionFactory.Function( - "CONVERT", - new[] { _sqlExpressionFactory.Fragment(storeType), instance }, - nullable: true, - argumentsPropagateNullability: new bool[] { false, true }, - typeof(string)) - : null; + ? _sqlExpressionFactory.Function( + "CONVERT", + new[] { _sqlExpressionFactory.Fragment(storeType), instance }, + nullable: true, + argumentsPropagateNullability: new[] { false, true }, + typeof(string)) + : null; } } } diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerQueryCompilationContext.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerQueryCompilationContext.cs index f08868bf034..3c989dd4ff7 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerQueryCompilationContext.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerQueryCompilationContext.cs @@ -3,7 +3,6 @@ using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Query; -using Microsoft.EntityFrameworkCore.Storage; namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal { @@ -39,8 +38,9 @@ public SqlServerQueryCompilationContext( /// 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 override bool IsBuffering => base.IsBuffering - || (QuerySplittingBehavior == EntityFrameworkCore.QuerySplittingBehavior.SplitQuery - && !_multipleActiveResultSetsEnabled); + public override bool IsBuffering + => base.IsBuffering + || (QuerySplittingBehavior == EntityFrameworkCore.QuerySplittingBehavior.SplitQuery + && !_multipleActiveResultSetsEnabled); } } diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs index 74d5be79031..7c311dce37f 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System.Linq.Expressions; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Query; using Microsoft.EntityFrameworkCore.Query.SqlExpressions; diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerSqlTranslatingExpressionVisitor.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerSqlTranslatingExpressionVisitor.cs index fdd5f952b00..9e0617ca31b 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerSqlTranslatingExpressionVisitor.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerSqlTranslatingExpressionVisitor.cs @@ -63,7 +63,7 @@ protected override Expression VisitBinary(BinaryExpression binaryExpression) Check.NotNull(binaryExpression, nameof(binaryExpression)); return !(base.VisitBinary(binaryExpression) is SqlExpression visitedExpression) - ? (Expression)null + ? null : (Expression)(visitedExpression is SqlBinaryExpression sqlBinary && _arithmeticOperatorTypes.Contains(sqlBinary.OperatorType) && (_dateTimeDataTypes.Contains(GetProviderType(sqlBinary.Left)) @@ -93,7 +93,7 @@ protected override Expression VisitUnary(UnaryExpression unaryExpression) "DATALENGTH", new[] { sqlExpression }, nullable: true, - argumentsPropagateNullability: new bool[] { true }, + argumentsPropagateNullability: new[] { true }, isBinaryMaxDataType ? typeof(long) : typeof(int)); return isBinaryMaxDataType @@ -123,6 +123,7 @@ public override SqlExpression TranslateLongCount(SqlExpression sqlExpression) typeof(long))); } - private static string GetProviderType(SqlExpression expression) => expression.TypeMapping?.StoreType; + private static string GetProviderType(SqlExpression expression) + => expression.TypeMapping?.StoreType; } } diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerStringMemberTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerStringMemberTranslator.cs index ccf0a16441e..2965df0c3a4 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerStringMemberTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerStringMemberTranslator.cs @@ -39,7 +39,10 @@ public SqlServerStringMemberTranslator([NotNull] ISqlExpressionFactory sqlExpres /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MemberInfo member, Type returnType, IDiagnosticsLogger logger) + SqlExpression instance, + MemberInfo member, + Type returnType, + IDiagnosticsLogger logger) { Check.NotNull(member, nameof(member)); Check.NotNull(returnType, nameof(returnType)); diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerStringMethodTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerStringMethodTranslator.cs index cc3a8e429a7..9afc44cb09c 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerStringMethodTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerStringMethodTranslator.cs @@ -70,14 +70,14 @@ private static readonly MethodInfo _endsWithMethodInfo = typeof(string).GetRuntimeMethod(nameof(string.EndsWith), new[] { typeof(string) }); private static readonly MethodInfo _firstOrDefaultMethodInfoWithoutArgs - = typeof(Enumerable).GetRuntimeMethods().Single( - m => m.Name == nameof(Enumerable.FirstOrDefault) - && m.GetParameters().Length == 1).MakeGenericMethod(new[] { typeof(char) }); + = typeof(Enumerable).GetRuntimeMethods().Single( + m => m.Name == nameof(Enumerable.FirstOrDefault) + && m.GetParameters().Length == 1).MakeGenericMethod(typeof(char)); private static readonly MethodInfo _lastOrDefaultMethodInfoWithoutArgs - = typeof(Enumerable).GetRuntimeMethods().Single( + = typeof(Enumerable).GetRuntimeMethods().Single( m => m.Name == nameof(Enumerable.LastOrDefault) - && m.GetParameters().Length == 1).MakeGenericMethod(new[] { typeof(char) }); + && m.GetParameters().Length == 1).MakeGenericMethod(typeof(char)); private readonly ISqlExpressionFactory _sqlExpressionFactory; @@ -102,7 +102,10 @@ public SqlServerStringMethodTranslator([NotNull] ISqlExpressionFactory sqlExpres /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) + SqlExpression instance, + MethodInfo method, + IReadOnlyList arguments, + IDiagnosticsLogger logger) { Check.NotNull(method, nameof(method)); Check.NotNull(arguments, nameof(arguments)); @@ -332,20 +335,22 @@ public virtual SqlExpression Translate( method.ReturnType); } - if (_lastOrDefaultMethodInfoWithoutArgs.Equals(method)) { var argument = arguments[0]; return _sqlExpressionFactory.Function( "SUBSTRING", - new[] { argument, - _sqlExpressionFactory.Function( - "LEN", - new[] { argument }, - nullable: true, - argumentsPropagateNullability: new[] { true }, - typeof(int)), - _sqlExpressionFactory.Constant(1) }, + new[] + { + argument, + _sqlExpressionFactory.Function( + "LEN", + new[] { argument }, + nullable: true, + argumentsPropagateNullability: new[] { true }, + typeof(int)), + _sqlExpressionFactory.Constant(1) + }, nullable: true, argumentsPropagateNullability: new[] { true, true, true }, method.ReturnType); @@ -439,7 +444,8 @@ private SqlExpression TranslateStartsEndsWith(SqlExpression instance, SqlExpress } // See https://docs.microsoft.com/en-us/sql/t-sql/language-elements/like-transact-sql - private bool IsLikeWildChar(char c) => c == '%' || c == '_' || c == '['; + private bool IsLikeWildChar(char c) + => c == '%' || c == '_' || c == '['; private string EscapeLikePattern(string pattern) { diff --git a/src/EFCore.SqlServer/Query/Internal/SqlServerTimeSpanMemberTranslator.cs b/src/EFCore.SqlServer/Query/Internal/SqlServerTimeSpanMemberTranslator.cs index 157ba379b51..85d644ab24a 100644 --- a/src/EFCore.SqlServer/Query/Internal/SqlServerTimeSpanMemberTranslator.cs +++ b/src/EFCore.SqlServer/Query/Internal/SqlServerTimeSpanMemberTranslator.cs @@ -21,12 +21,12 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal public class SqlServerTimeSpanMemberTranslator : IMemberTranslator { private static readonly Dictionary _datePartMappings = new Dictionary - { - { nameof(TimeSpan.Hours), "hour" }, - { nameof(TimeSpan.Minutes), "minute" }, - { nameof(TimeSpan.Seconds), "second" }, - { nameof(TimeSpan.Milliseconds), "millisecond" } - }; + { + { nameof(TimeSpan.Hours), "hour" }, + { nameof(TimeSpan.Minutes), "minute" }, + { nameof(TimeSpan.Seconds), "second" }, + { nameof(TimeSpan.Milliseconds), "millisecond" } + }; private readonly ISqlExpressionFactory _sqlExpressionFactory; @@ -48,7 +48,10 @@ public SqlServerTimeSpanMemberTranslator([NotNull] ISqlExpressionFactory sqlExpr /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MemberInfo member, Type returnType, IDiagnosticsLogger logger) + SqlExpression instance, + MemberInfo member, + Type returnType, + IDiagnosticsLogger logger) { Check.NotNull(member, nameof(member)); Check.NotNull(returnType, nameof(returnType)); @@ -56,13 +59,10 @@ public virtual SqlExpression Translate( if (member.DeclaringType == typeof(TimeSpan) && _datePartMappings.TryGetValue(member.Name, out string value)) { - return _sqlExpressionFactory.Function("DATEPART", new [] - { - _sqlExpressionFactory.Fragment(value), - instance - }, + return _sqlExpressionFactory.Function( + "DATEPART", new[] { _sqlExpressionFactory.Fragment(value), instance }, nullable: true, - argumentsPropagateNullability: new [] { false, true }, + argumentsPropagateNullability: new[] { false, true }, returnType); } diff --git a/src/EFCore.SqlServer/Scaffolding/Internal/SqlDataReaderExtension.cs b/src/EFCore.SqlServer/Scaffolding/Internal/SqlDataReaderExtension.cs index 32015ae2fb1..15abddbfb8d 100644 --- a/src/EFCore.SqlServer/Scaffolding/Internal/SqlDataReaderExtension.cs +++ b/src/EFCore.SqlServer/Scaffolding/Internal/SqlDataReaderExtension.cs @@ -21,7 +21,7 @@ public static class SqlDataReaderExtension /// 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. /// - [return: CA.MaybeNull] + [return: CA.MaybeNullAttribute] public static T GetValueOrDefault([NotNull] this DbDataReader reader, [NotNull] string name) { var idx = reader.GetOrdinal(name); @@ -36,7 +36,7 @@ public static T GetValueOrDefault([NotNull] this DbDataReader reader, [NotNul /// 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. /// - [return: CA.MaybeNull] + [return: CA.MaybeNullAttribute] public static T GetValueOrDefault([NotNull] this DbDataRecord record, [NotNull] string name) { var idx = record.GetOrdinal(name); diff --git a/src/EFCore.SqlServer/Scaffolding/Internal/SqlServerDatabaseModelFactory.cs b/src/EFCore.SqlServer/Scaffolding/Internal/SqlServerDatabaseModelFactory.cs index 7c95152376b..d2949b99e95 100644 --- a/src/EFCore.SqlServer/Scaffolding/Internal/SqlServerDatabaseModelFactory.cs +++ b/src/EFCore.SqlServer/Scaffolding/Internal/SqlServerDatabaseModelFactory.cs @@ -13,7 +13,6 @@ using Microsoft.Data.SqlClient; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Metadata.Internal; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Scaffolding; using Microsoft.EntityFrameworkCore.Scaffolding.Metadata; @@ -333,7 +332,8 @@ private static (string? Schema, string Table) Parse(string table) }) : (Func?)null; - private static string EscapeLiteral(string s) => $"N'{s}'"; + private static string EscapeLiteral(string s) + => $"N'{s}'"; private IReadOnlyDictionary GetTypeAliases(DbConnection connection) { diff --git a/src/EFCore.SqlServer/Storage/Internal/SqlServerConnection.cs b/src/EFCore.SqlServer/Storage/Internal/SqlServerConnection.cs index 2450da0cd54..2114f657796 100644 --- a/src/EFCore.SqlServer/Storage/Internal/SqlServerConnection.cs +++ b/src/EFCore.SqlServer/Storage/Internal/SqlServerConnection.cs @@ -28,6 +28,7 @@ public class SqlServerConnection : RelationalConnection, ISqlServerConnection { // Compensate for slow SQL Server database creation private const int DefaultMasterConnectionCommandTimeout = 60; + private static readonly ConcurrentDictionary _multipleActiveResultSetsEnabledMap = new ConcurrentDictionary(); @@ -68,7 +69,8 @@ protected override void OpenDbConnection(bool errorsExpected) /// 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. /// - protected override DbConnection CreateDbConnection() => new SqlConnection(GetValidatedConnectionString()); + protected override DbConnection CreateDbConnection() + => new SqlConnection(GetValidatedConnectionString()); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -102,14 +104,16 @@ public virtual bool IsMultipleActiveResultSetsEnabled { var connectionString = ConnectionString; - return connectionString != null && _multipleActiveResultSetsEnabledMap.GetOrAdd( - connectionString, cs => new SqlConnectionStringBuilder(cs).MultipleActiveResultSets); + return connectionString != null + && _multipleActiveResultSetsEnabledMap.GetOrAdd( + connectionString, cs => new SqlConnectionStringBuilder(cs).MultipleActiveResultSets); } } /// /// Indicates whether the store connection supports ambient transactions /// - protected override bool SupportsAmbientTransactions => true; + protected override bool SupportsAmbientTransactions + => true; } } diff --git a/src/EFCore.SqlServer/Storage/Internal/SqlServerDatabaseCreator.cs b/src/EFCore.SqlServer/Storage/Internal/SqlServerDatabaseCreator.cs index 864ac8061b3..ddf6248c3a7 100644 --- a/src/EFCore.SqlServer/Storage/Internal/SqlServerDatabaseCreator.cs +++ b/src/EFCore.SqlServer/Storage/Internal/SqlServerDatabaseCreator.cs @@ -309,8 +309,8 @@ await _rawSqlCommandBuilder // Login failed is thrown when database does not exist (See Issue #776) // Unable to attach database file is thrown when file does not exist (See Issue #2810) // Unable to open the physical file is thrown when file does not exist (See Issue #2810) - private static bool IsDoesNotExist(SqlException exception) => - exception.Number == 4060 || exception.Number == 1832 || exception.Number == 5120; + private static bool IsDoesNotExist(SqlException exception) + => exception.Number == 4060 || exception.Number == 1832 || exception.Number == 5120; // See Issue #985 private bool RetryOnExistsFailure(SqlException exception) @@ -391,10 +391,12 @@ private IReadOnlyList CreateDropCommands() } // Clear connection pools in case there are active connections that are pooled - private static void ClearAllPools() => SqlConnection.ClearAllPools(); + private static void ClearAllPools() + => SqlConnection.ClearAllPools(); // Clear connection pool for the database connection since after the 'create database' call, a previously // invalid connection may now be valid. - private void ClearPool() => SqlConnection.ClearPool((SqlConnection)_connection.DbConnection); + private void ClearPool() + => SqlConnection.ClearPool((SqlConnection)_connection.DbConnection); } } diff --git a/src/EFCore.SqlServer/Storage/Internal/SqlServerDateTimeOffsetTypeMapping.cs b/src/EFCore.SqlServer/Storage/Internal/SqlServerDateTimeOffsetTypeMapping.cs index 562c5766e66..1a48874d551 100644 --- a/src/EFCore.SqlServer/Storage/Internal/SqlServerDateTimeOffsetTypeMapping.cs +++ b/src/EFCore.SqlServer/Storage/Internal/SqlServerDateTimeOffsetTypeMapping.cs @@ -42,10 +42,10 @@ public SqlServerDateTimeOffsetTypeMapping( DbType? dbType = System.Data.DbType.DateTimeOffset) : base( new RelationalTypeMappingParameters( - new CoreTypeMappingParameters(typeof(DateTimeOffset)), - storeType, - StoreTypePostfix.Precision, - dbType)) + new CoreTypeMappingParameters(typeof(DateTimeOffset)), + storeType, + StoreTypePostfix.Precision, + dbType)) { } diff --git a/src/EFCore.SqlServer/Storage/Internal/SqlServerDateTimeTypeMapping.cs b/src/EFCore.SqlServer/Storage/Internal/SqlServerDateTimeTypeMapping.cs index aa3d68fb211..345820b4375 100644 --- a/src/EFCore.SqlServer/Storage/Internal/SqlServerDateTimeTypeMapping.cs +++ b/src/EFCore.SqlServer/Storage/Internal/SqlServerDateTimeTypeMapping.cs @@ -47,10 +47,10 @@ public SqlServerDateTimeTypeMapping( DbType? dbType = null) : base( new RelationalTypeMappingParameters( - new CoreTypeMappingParameters(typeof(DateTime)), - storeType, - StoreTypePostfix.Precision, - dbType)) + new CoreTypeMappingParameters(typeof(DateTime)), + storeType, + StoreTypePostfix.Precision, + dbType)) { } diff --git a/src/EFCore.SqlServer/Storage/Internal/SqlServerDoubleTypeMapping.cs b/src/EFCore.SqlServer/Storage/Internal/SqlServerDoubleTypeMapping.cs index 0fc5d29ae70..6c062a79947 100644 --- a/src/EFCore.SqlServer/Storage/Internal/SqlServerDoubleTypeMapping.cs +++ b/src/EFCore.SqlServer/Storage/Internal/SqlServerDoubleTypeMapping.cs @@ -28,10 +28,10 @@ public SqlServerDoubleTypeMapping( DbType? dbType = null) : base( new RelationalTypeMappingParameters( - new CoreTypeMappingParameters(typeof(double)), - storeType, - StoreTypePostfix.Precision, - dbType)) + new CoreTypeMappingParameters(typeof(double)), + storeType, + StoreTypePostfix.Precision, + dbType)) { } diff --git a/src/EFCore.SqlServer/Storage/Internal/SqlServerExecutionStrategy.cs b/src/EFCore.SqlServer/Storage/Internal/SqlServerExecutionStrategy.cs index aef70fbf022..905030da64e 100644 --- a/src/EFCore.SqlServer/Storage/Internal/SqlServerExecutionStrategy.cs +++ b/src/EFCore.SqlServer/Storage/Internal/SqlServerExecutionStrategy.cs @@ -37,7 +37,8 @@ public SqlServerExecutionStrategy([NotNull] ExecutionStrategyDependencies depend /// 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 virtual bool RetriesOnFailure => false; + public virtual bool RetriesOnFailure + => false; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.SqlServer/Storage/Internal/SqlServerFloatTypeMapping.cs b/src/EFCore.SqlServer/Storage/Internal/SqlServerFloatTypeMapping.cs index 9cbc5370ade..57eaafbc191 100644 --- a/src/EFCore.SqlServer/Storage/Internal/SqlServerFloatTypeMapping.cs +++ b/src/EFCore.SqlServer/Storage/Internal/SqlServerFloatTypeMapping.cs @@ -27,10 +27,10 @@ public SqlServerFloatTypeMapping( DbType? dbType = null) : base( new RelationalTypeMappingParameters( - new CoreTypeMappingParameters(typeof(float)), - storeType, - StoreTypePostfix.Precision, - dbType)) + new CoreTypeMappingParameters(typeof(float)), + storeType, + StoreTypePostfix.Precision, + dbType)) { } diff --git a/src/EFCore.SqlServer/Storage/Internal/SqlServerSqlGenerationHelper.cs b/src/EFCore.SqlServer/Storage/Internal/SqlServerSqlGenerationHelper.cs index 1d40f8ab682..6cd4dccb921 100644 --- a/src/EFCore.SqlServer/Storage/Internal/SqlServerSqlGenerationHelper.cs +++ b/src/EFCore.SqlServer/Storage/Internal/SqlServerSqlGenerationHelper.cs @@ -42,7 +42,8 @@ public SqlServerSqlGenerationHelper([NotNull] RelationalSqlGenerationHelperDepen /// 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 override string BatchTerminator => "GO" + Environment.NewLine + Environment.NewLine; + public override string BatchTerminator + => "GO" + Environment.NewLine + Environment.NewLine; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -50,7 +51,8 @@ public SqlServerSqlGenerationHelper([NotNull] RelationalSqlGenerationHelperDepen /// 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 override string StartTransactionStatement => "BEGIN TRANSACTION" + StatementTerminator; + public override string StartTransactionStatement + => "BEGIN TRANSACTION" + StatementTerminator; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.SqlServer/Storage/Internal/SqlServerStringTypeMapping.cs b/src/EFCore.SqlServer/Storage/Internal/SqlServerStringTypeMapping.cs index 434114df51e..fead67a3482 100644 --- a/src/EFCore.SqlServer/Storage/Internal/SqlServerStringTypeMapping.cs +++ b/src/EFCore.SqlServer/Storage/Internal/SqlServerStringTypeMapping.cs @@ -51,19 +51,21 @@ public SqlServerStringTypeMapping( { } - private static string GetStoreName(bool unicode, bool fixedLength) => unicode - ? fixedLength ? "nchar" : "nvarchar" - : fixedLength - ? "char" - : "varchar"; - - private static DbType? GetDbType(bool unicode, bool fixedLength) => unicode - ? (fixedLength - ? System.Data.DbType.StringFixedLength - : (DbType?)null) - : (fixedLength - ? System.Data.DbType.AnsiStringFixedLength - : System.Data.DbType.AnsiString); + private static string GetStoreName(bool unicode, bool fixedLength) + => unicode + ? fixedLength ? "nchar" : "nvarchar" + : fixedLength + ? "char" + : "varchar"; + + private static DbType? GetDbType(bool unicode, bool fixedLength) + => unicode + ? (fixedLength + ? System.Data.DbType.StringFixedLength + : (DbType?)null) + : (fixedLength + ? System.Data.DbType.AnsiStringFixedLength + : System.Data.DbType.AnsiString); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -161,7 +163,8 @@ protected override void ConfigureParameter(DbParameter parameter) protected override string GenerateNonNullSqlLiteral(object value) => EscapeLineBreaks(EscapeSqlLiteral((string)value)); - private static readonly char[] LineBreakChars = new char[] { '\r', '\n' }; + private static readonly char[] LineBreakChars = { '\r', '\n' }; + private string EscapeLineBreaks(string value) { var unicodePrefix = IsUnicode ? "N" : string.Empty; @@ -177,11 +180,13 @@ private string EscapeLineBreaks(string value) return value[0] == '\n' ? "CHAR(10)" : "CHAR(13)"; } - return ($"CONCAT({unicodePrefix}'" + value - .Replace("\r", $"', CHAR(13), {unicodePrefix}'") - .Replace("\n", $"', CHAR(10), {unicodePrefix}'") + "')") - .Replace($"{unicodePrefix}'', ", string.Empty) - .Replace($", {unicodePrefix}''", string.Empty); + return ($"CONCAT({unicodePrefix}'" + + value + .Replace("\r", $"', CHAR(13), {unicodePrefix}'") + .Replace("\n", $"', CHAR(10), {unicodePrefix}'") + + "')") + .Replace($"{unicodePrefix}'', ", string.Empty) + .Replace($", {unicodePrefix}''", string.Empty); } } } diff --git a/src/EFCore.SqlServer/Storage/Internal/SqlServerTransaction.cs b/src/EFCore.SqlServer/Storage/Internal/SqlServerTransaction.cs index fe207edb028..56ca777fa36 100644 --- a/src/EFCore.SqlServer/Storage/Internal/SqlServerTransaction.cs +++ b/src/EFCore.SqlServer/Storage/Internal/SqlServerTransaction.cs @@ -36,13 +36,15 @@ public SqlServerTransaction( } /// - protected override string GetCreateSavepointSql(string name) => "SAVE TRANSACTION " + name; + protected override string GetCreateSavepointSql(string name) + => "SAVE TRANSACTION " + name; /// - protected override string GetRollbackToSavepointSql(string name) => "ROLLBACK TRANSACTION " + name; + protected override string GetRollbackToSavepointSql(string name) + => "ROLLBACK TRANSACTION " + name; /// - public override void ReleaseSavepoint(string name) {} + public override void ReleaseSavepoint(string name) { } /// public override Task ReleaseSavepointAsync(string name, CancellationToken cancellationToken = default) diff --git a/src/EFCore.SqlServer/Storage/Internal/SqlServerTransactionFactory.cs b/src/EFCore.SqlServer/Storage/Internal/SqlServerTransactionFactory.cs index 69522130196..da75b8ce65d 100644 --- a/src/EFCore.SqlServer/Storage/Internal/SqlServerTransactionFactory.cs +++ b/src/EFCore.SqlServer/Storage/Internal/SqlServerTransactionFactory.cs @@ -23,7 +23,11 @@ public class SqlServerTransactionFactory : IRelationalTransactionFactory /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual RelationalTransaction Create( - IRelationalConnection connection, DbTransaction transaction, Guid transactionId, IDiagnosticsLogger logger, bool transactionOwned) + IRelationalConnection connection, + DbTransaction transaction, + Guid transactionId, + IDiagnosticsLogger logger, + bool transactionOwned) => new SqlServerTransaction(connection, transaction, transactionId, logger, transactionOwned); } } diff --git a/src/EFCore.SqlServer/Storage/Internal/SqlServerTypeMappingSource.cs b/src/EFCore.SqlServer/Storage/Internal/SqlServerTypeMappingSource.cs index 2ae11062f82..ea0c1bf0f6a 100644 --- a/src/EFCore.SqlServer/Storage/Internal/SqlServerTypeMappingSource.cs +++ b/src/EFCore.SqlServer/Storage/Internal/SqlServerTypeMappingSource.cs @@ -313,7 +313,16 @@ private RelationalTypeMapping FindRawMapping(RelationalTypeMappingInfo mappingIn } private static readonly List _nameBasesUsingPrecision = - new List { "decimal", "dec", "numeric", "datetime2", "datetimeoffset", "double precision", "float" }; + new List + { + "decimal", + "dec", + "numeric", + "datetime2", + "datetimeoffset", + "double precision", + "float" + }; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.SqlServer/Storage/Internal/SqlServerUdtTypeMapping.cs b/src/EFCore.SqlServer/Storage/Internal/SqlServerUdtTypeMapping.cs index 61b8aed925b..bf346613270 100644 --- a/src/EFCore.SqlServer/Storage/Internal/SqlServerUdtTypeMapping.cs +++ b/src/EFCore.SqlServer/Storage/Internal/SqlServerUdtTypeMapping.cs @@ -4,7 +4,6 @@ using System; using System.Data; using System.Data.Common; -using System.Data.SqlTypes; using System.Linq.Expressions; using System.Threading; using JetBrains.Annotations; diff --git a/src/EFCore.SqlServer/Update/Internal/SqlServerModificationCommandBatch.cs b/src/EFCore.SqlServer/Update/Internal/SqlServerModificationCommandBatch.cs index a8425519522..6d9ad8c5b26 100644 --- a/src/EFCore.SqlServer/Update/Internal/SqlServerModificationCommandBatch.cs +++ b/src/EFCore.SqlServer/Update/Internal/SqlServerModificationCommandBatch.cs @@ -54,7 +54,8 @@ public SqlServerModificationCommandBatch( /// 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. /// - protected new virtual ISqlServerUpdateSqlGenerator UpdateSqlGenerator => (ISqlServerUpdateSqlGenerator)base.UpdateSqlGenerator; + protected new virtual ISqlServerUpdateSqlGenerator UpdateSqlGenerator + => (ISqlServerUpdateSqlGenerator)base.UpdateSqlGenerator; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.SqlServer/Update/Internal/SqlServerUpdateSqlGenerator.cs b/src/EFCore.SqlServer/Update/Internal/SqlServerUpdateSqlGenerator.cs index a94f24576bb..a742a1379a3 100644 --- a/src/EFCore.SqlServer/Update/Internal/SqlServerUpdateSqlGenerator.cs +++ b/src/EFCore.SqlServer/Update/Internal/SqlServerUpdateSqlGenerator.cs @@ -145,7 +145,8 @@ private ResultSetMapping AppendBulkInsertWithoutServerValues( for (var i = 1; i < modificationCommands.Count; i++) { commandStringBuilder.AppendLine(","); - AppendValues(commandStringBuilder, name, schema, modificationCommands[i].ColumnModifications.Where(o => o.IsWrite).ToList()); + AppendValues( + commandStringBuilder, name, schema, modificationCommands[i].ColumnModifications.Where(o => o.IsWrite).ToList()); } commandStringBuilder.AppendLine(SqlGenerationHelper.StatementTerminator); @@ -491,7 +492,10 @@ private ResultSetMapping AppendSelectCommand( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ResultSetMapping AppendSelectAffectedCountCommand( - StringBuilder commandStringBuilder, string name, string schema, int commandPosition) + StringBuilder commandStringBuilder, + string name, + string schema, + int commandPosition) { commandStringBuilder .Append("SELECT @@ROWCOUNT") diff --git a/src/EFCore.SqlServer/Utilities/EnumerableExtensions.cs b/src/EFCore.SqlServer/Utilities/EnumerableExtensions.cs index cc3c544965e..fdc87fba6b8 100644 --- a/src/EFCore.SqlServer/Utilities/EnumerableExtensions.cs +++ b/src/EFCore.SqlServer/Utilities/EnumerableExtensions.cs @@ -14,7 +14,8 @@ public static string Join(this IEnumerable source, string separator = ", => string.Join(separator, source); public static IEnumerable Distinct( - this IEnumerable source, Func comparer) + this IEnumerable source, + Func comparer) where T : class => source.Distinct(new DynamicEqualityComparer(comparer)); @@ -28,9 +29,11 @@ public DynamicEqualityComparer(Func func) _func = func; } - public bool Equals(T x, T y) => _func(x, y); + public bool Equals(T x, T y) + => _func(x, y); - public int GetHashCode(T obj) => 0; // force Equals + public int GetHashCode(T obj) + => 0; // force Equals } } } diff --git a/src/EFCore.SqlServer/ValueGeneration/Internal/SqlServerSequenceHiLoValueGenerator.cs b/src/EFCore.SqlServer/ValueGeneration/Internal/SqlServerSequenceHiLoValueGenerator.cs index 70cb93ab3a1..45d12dd4c9c 100644 --- a/src/EFCore.SqlServer/ValueGeneration/Internal/SqlServerSequenceHiLoValueGenerator.cs +++ b/src/EFCore.SqlServer/ValueGeneration/Internal/SqlServerSequenceHiLoValueGenerator.cs @@ -98,6 +98,7 @@ await _rawSqlCommandBuilder /// 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 override bool GeneratesTemporaryValues => false; + public override bool GeneratesTemporaryValues + => false; } } diff --git a/src/EFCore.SqlServer/ValueGeneration/Internal/SqlServerValueGeneratorSelector.cs b/src/EFCore.SqlServer/ValueGeneration/Internal/SqlServerValueGeneratorSelector.cs index 8b82fdbdd3b..675f3f16583 100644 --- a/src/EFCore.SqlServer/ValueGeneration/Internal/SqlServerValueGeneratorSelector.cs +++ b/src/EFCore.SqlServer/ValueGeneration/Internal/SqlServerValueGeneratorSelector.cs @@ -60,7 +60,8 @@ public SqlServerValueGeneratorSelector( /// 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 new virtual ISqlServerValueGeneratorCache Cache => (ISqlServerValueGeneratorCache)base.Cache; + public new virtual ISqlServerValueGeneratorCache Cache + => (ISqlServerValueGeneratorCache)base.Cache; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Sqlite.Core/Diagnostics/Internal/UnexpectedConnectionTypeEventData.cs b/src/EFCore.Sqlite.Core/Diagnostics/Internal/UnexpectedConnectionTypeEventData.cs index 3554d7ddb52..386a1129d42 100644 --- a/src/EFCore.Sqlite.Core/Diagnostics/Internal/UnexpectedConnectionTypeEventData.cs +++ b/src/EFCore.Sqlite.Core/Diagnostics/Internal/UnexpectedConnectionTypeEventData.cs @@ -1,21 +1,21 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.EntityFrameworkCore.Diagnostics; using System; using System.Diagnostics; using JetBrains.Annotations; +using Microsoft.EntityFrameworkCore.Diagnostics; namespace Microsoft.EntityFrameworkCore.Sqlite.Diagnostics.Internal { /// /// The event payload for - /// . + /// . /// public class UnexpectedConnectionTypeEventData : EventData { /// - /// Constructs the event payload. + /// Constructs the event payload. /// /// The event definition. /// A delegate that generates a log message for this event. diff --git a/src/EFCore.Sqlite.Core/Diagnostics/SqliteEventId.cs b/src/EFCore.Sqlite.Core/Diagnostics/SqliteEventId.cs index da404b31147..a7fb794c4af 100644 --- a/src/EFCore.Sqlite.Core/Diagnostics/SqliteEventId.cs +++ b/src/EFCore.Sqlite.Core/Diagnostics/SqliteEventId.cs @@ -48,7 +48,9 @@ private enum Id } private static readonly string _validationPrefix = DbLoggerCategory.Model.Validation.Name + "."; - private static EventId MakeValidationId(Id id) => new EventId((int)id, _validationPrefix + id); + + private static EventId MakeValidationId(Id id) + => new EventId((int)id, _validationPrefix + id); /// /// @@ -77,7 +79,9 @@ private enum Id public static readonly EventId SequenceConfiguredWarning = MakeValidationId(Id.SequenceConfiguredWarning); private static readonly string _infraPrefix = DbLoggerCategory.Infrastructure.Name + "."; - private static EventId MakeInfraId(Id id) => new EventId((int)id, _infraPrefix + id); + + private static EventId MakeInfraId(Id id) + => new EventId((int)id, _infraPrefix + id); /// /// @@ -94,7 +98,9 @@ private enum Id public static readonly EventId UnexpectedConnectionTypeWarning = MakeInfraId(Id.UnexpectedConnectionTypeWarning); private static readonly string _migrationsPrefix = DbLoggerCategory.Migrations.Name + "."; - private static EventId MakeMigrationsId(Id id) => new EventId((int)id, _migrationsPrefix + id); + + private static EventId MakeMigrationsId(Id id) + => new EventId((int)id, _migrationsPrefix + id); /// /// An operation may fail due to a pending rebuild of the table. @@ -103,7 +109,9 @@ private enum Id public static readonly EventId TableRebuildPendingWarning = MakeMigrationsId(Id.TableRebuildPendingWarning); private static readonly string _scaffoldingPrefix = DbLoggerCategory.Scaffolding.Name + "."; - private static EventId MakeScaffoldingId(Id id) => new EventId((int)id, _scaffoldingPrefix + id); + + private static EventId MakeScaffoldingId(Id id) + => new EventId((int)id, _scaffoldingPrefix + id); /// /// A column was found. diff --git a/src/EFCore.Sqlite.Core/Extensions/SqliteDatabaseFacadeExtensions.cs b/src/EFCore.Sqlite.Core/Extensions/SqliteDatabaseFacadeExtensions.cs index 44f7538ae42..48add21e278 100644 --- a/src/EFCore.Sqlite.Core/Extensions/SqliteDatabaseFacadeExtensions.cs +++ b/src/EFCore.Sqlite.Core/Extensions/SqliteDatabaseFacadeExtensions.cs @@ -16,7 +16,7 @@ public static class SqliteDatabaseFacadeExtensions { /// /// - /// Returns if the database provider currently in use is the SQLite provider. + /// Returns if the database provider currently in use is the SQLite provider. /// /// /// This method can only be used after the has been configured because @@ -26,7 +26,7 @@ public static class SqliteDatabaseFacadeExtensions /// /// /// The facade from . - /// if SQLite is being used; otherwise. + /// if SQLite is being used; otherwise. public static bool IsSqlite([NotNull] this DatabaseFacade database) => database.ProviderName.Equals( typeof(SqliteOptionsExtension).Assembly.GetName().Name, diff --git a/src/EFCore.Sqlite.Core/Extensions/SqliteMigrationBuilderExtensions.cs b/src/EFCore.Sqlite.Core/Extensions/SqliteMigrationBuilderExtensions.cs index 7a516a0665d..1caef32905d 100644 --- a/src/EFCore.Sqlite.Core/Extensions/SqliteMigrationBuilderExtensions.cs +++ b/src/EFCore.Sqlite.Core/Extensions/SqliteMigrationBuilderExtensions.cs @@ -15,14 +15,14 @@ public static class SqliteMigrationBuilderExtensions { /// /// - /// Returns if the database provider currently in use is the SQLite provider. + /// Returns if the database provider currently in use is the SQLite provider. /// /// /// /// The migrationBuilder from the parameters on or /// . /// - /// if SQLite is being used; otherwise. + /// if SQLite is being used; otherwise. public static bool IsSqlite([NotNull] this MigrationBuilder migrationBuilder) => string.Equals( migrationBuilder.ActiveProvider, diff --git a/src/EFCore.Sqlite.Core/Infrastructure/Internal/SqliteOptionsExtension.cs b/src/EFCore.Sqlite.Core/Infrastructure/Internal/SqliteOptionsExtension.cs index 14ca8d2bcae..67663f14692 100644 --- a/src/EFCore.Sqlite.Core/Infrastructure/Internal/SqliteOptionsExtension.cs +++ b/src/EFCore.Sqlite.Core/Infrastructure/Internal/SqliteOptionsExtension.cs @@ -68,7 +68,8 @@ protected override RelationalOptionsExtension Clone() /// 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 virtual bool LoadSpatialite => _loadSpatialite; + public virtual bool LoadSpatialite + => _loadSpatialite; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to @@ -106,7 +107,8 @@ public ExtensionInfo(IDbContextOptionsExtension extension) private new SqliteOptionsExtension Extension => (SqliteOptionsExtension)base.Extension; - public override bool IsDatabaseProvider => true; + public override bool IsDatabaseProvider + => true; public override string LogFragment { diff --git a/src/EFCore.Sqlite.Core/Infrastructure/SpatialiteLoader.cs b/src/EFCore.Sqlite.Core/Infrastructure/SpatialiteLoader.cs index a4bfe769a39..fdd91b5bccd 100644 --- a/src/EFCore.Sqlite.Core/Infrastructure/SpatialiteLoader.cs +++ b/src/EFCore.Sqlite.Core/Infrastructure/SpatialiteLoader.cs @@ -47,7 +47,7 @@ static SpatialiteLoader() /// Tries to load the mod_spatialite extension into the specified connection. /// /// The connection. - /// if the extension was loaded; otherwise, . + /// if the extension was loaded; otherwise, . public static bool TryLoad([NotNull] DbConnection connection) { Check.NotNull(connection, nameof(connection)); @@ -206,10 +206,10 @@ private static void FindExtension() if (currentPath == null || !currentPath.Split(Path.PathSeparator).Any( - p => string.Equals( - p.TrimEnd(Path.DirectorySeparatorChar), - assetDirectory, - StringComparison.OrdinalIgnoreCase))) + p => string.Equals( + p.TrimEnd(Path.DirectorySeparatorChar), + assetDirectory, + StringComparison.OrdinalIgnoreCase))) { Environment.SetEnvironmentVariable( _pathVariableName, diff --git a/src/EFCore.Sqlite.Core/Internal/SqliteModelValidator.cs b/src/EFCore.Sqlite.Core/Internal/SqliteModelValidator.cs index 964eca6035d..6c8007a6ae0 100644 --- a/src/EFCore.Sqlite.Core/Internal/SqliteModelValidator.cs +++ b/src/EFCore.Sqlite.Core/Internal/SqliteModelValidator.cs @@ -60,7 +60,8 @@ public override void Validate(IModel model, IDiagnosticsLogger protected virtual void ValidateNoSchemas( - [NotNull] IModel model, [NotNull] IDiagnosticsLogger logger) + [NotNull] IModel model, + [NotNull] IDiagnosticsLogger logger) { foreach (var entityType in model.GetEntityTypes().Where(e => e.GetSchema() != null)) { @@ -75,7 +76,8 @@ protected virtual void ValidateNoSchemas( /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected virtual void ValidateNoSequences( - [NotNull] IModel model, [NotNull] IDiagnosticsLogger logger) + [NotNull] IModel model, + [NotNull] IDiagnosticsLogger logger) { foreach (var sequence in model.GetSequences()) { diff --git a/src/EFCore.Sqlite.Core/Migrations/Internal/SqliteHistoryRepository.cs b/src/EFCore.Sqlite.Core/Migrations/Internal/SqliteHistoryRepository.cs index d60e0c15a9f..a8be9359ee5 100644 --- a/src/EFCore.Sqlite.Core/Migrations/Internal/SqliteHistoryRepository.cs +++ b/src/EFCore.Sqlite.Core/Migrations/Internal/SqliteHistoryRepository.cs @@ -61,7 +61,8 @@ protected override string ExistsSql /// 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. /// - protected override bool InterpretExistsResult(object value) => (long)value != 0; + protected override bool InterpretExistsResult(object value) + => (long)value != 0; /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore.Sqlite.Core/Migrations/SqliteMigrationsSqlGenerator.cs b/src/EFCore.Sqlite.Core/Migrations/SqliteMigrationsSqlGenerator.cs index 18df04c939b..b8ee76d949c 100644 --- a/src/EFCore.Sqlite.Core/Migrations/SqliteMigrationsSqlGenerator.cs +++ b/src/EFCore.Sqlite.Core/Migrations/SqliteMigrationsSqlGenerator.cs @@ -51,7 +51,10 @@ public SqliteMigrationsSqlGenerator( /// The target model which may be if the operations exist without a model. /// The options to use when generating commands. /// The list of commands to be executed or scripted. - public override IReadOnlyList Generate(IReadOnlyList operations, IModel model = null, MigrationsSqlGenerationOptions options = MigrationsSqlGenerationOptions.Default) + public override IReadOnlyList Generate( + IReadOnlyList operations, + IModel model = null, + MigrationsSqlGenerationOptions options = MigrationsSqlGenerationOptions.Default) => base.Generate(RewriteOperations(operations, model), model, options); private bool IsSpatialiteColumn(AddColumnOperation operation, IModel model) @@ -311,9 +314,9 @@ private IReadOnlyList RewriteOperations( ColumnType = column.StoreType, IsNullable = column.IsNullable, DefaultValue = rebuild.Value.AddColumnsDeferred.TryGetValue(column.Name, out var originalOperation) - && !originalOperation.IsNullable - ? originalOperation.DefaultValue - : column.DefaultValue, + && !originalOperation.IsNullable + ? originalOperation.DefaultValue + : column.DefaultValue, DefaultValueSql = column.DefaultValueSql, ComputedColumnSql = column.ComputedColumnSql, IsStored = column.IsStored, @@ -380,10 +383,10 @@ private IReadOnlyList RewriteOperations( intoBuilder.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(column.Name)); var defaultValue = rebuild.Value.AlterColumnsDeferred.TryGetValue(column.Name, out var alterColumnOperation) - && !alterColumnOperation.IsNullable - && alterColumnOperation.OldColumn.IsNullable - ? alterColumnOperation.DefaultValue - : null; + && !alterColumnOperation.IsNullable + && alterColumnOperation.OldColumn.IsNullable + ? alterColumnOperation.DefaultValue + : null; if (defaultValue != null) { selectBuilder.Append("IFNULL("); @@ -436,21 +439,13 @@ private IReadOnlyList RewriteOperations( if (rebuilds.Any()) { operations.Add( - new SqlOperation - { - Sql = "PRAGMA foreign_keys = 0;", - SuppressTransaction = true - }); + new SqlOperation { Sql = "PRAGMA foreign_keys = 0;", SuppressTransaction = true }); } foreach (var rebuild in rebuilds) { operations.Add( - new DropTableOperation - { - Name = rebuild.Key.Table, - Schema = rebuild.Key.Schema - }); + new DropTableOperation { Name = rebuild.Key.Table, Schema = rebuild.Key.Schema }); operations.Add( new RenameTableOperation { @@ -464,11 +459,7 @@ private IReadOnlyList RewriteOperations( if (rebuilds.Any()) { operations.Add( - new SqlOperation - { - Sql = "PRAGMA foreign_keys = 1;", - SuppressTransaction = true - }); + new SqlOperation { Sql = "PRAGMA foreign_keys = 1;", SuppressTransaction = true }); } foreach (var index in indexesToRebuild) @@ -830,7 +821,10 @@ protected override void ColumnDefinition( /// The command builder to use to build the commands. /// Indicates whether or not to terminate the command after generating SQL for the operation. protected override void Generate( - AddForeignKeyOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true) + AddForeignKeyOperation operation, + IModel model, + MigrationCommandListBuilder builder, + bool terminate = true) => throw new NotSupportedException( SqliteStrings.InvalidMigrationOperation(operation.GetType().ShortDisplayName())); @@ -843,7 +837,10 @@ protected override void Generate( /// The command builder to use to build the commands. /// Indicates whether or not to terminate the command after generating SQL for the operation. protected override void Generate( - AddPrimaryKeyOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true) + AddPrimaryKeyOperation operation, + IModel model, + MigrationCommandListBuilder builder, + bool terminate = true) => throw new NotSupportedException( SqliteStrings.InvalidMigrationOperation(operation.GetType().ShortDisplayName())); @@ -878,7 +875,10 @@ protected override void Generate(AddCheckConstraintOperation operation, IModel m /// The command builder to use to build the commands. /// Indicates whether or not to terminate the command after generating SQL for the operation. protected override void Generate( - DropColumnOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true) + DropColumnOperation operation, + IModel model, + MigrationCommandListBuilder builder, + bool terminate = true) => throw new NotSupportedException( SqliteStrings.InvalidMigrationOperation(operation.GetType().ShortDisplayName())); @@ -891,7 +891,10 @@ protected override void Generate( /// The command builder to use to build the commands. /// Indicates whether or not to terminate the command after generating SQL for the operation. protected override void Generate( - DropForeignKeyOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true) + DropForeignKeyOperation operation, + IModel model, + MigrationCommandListBuilder builder, + bool terminate = true) => throw new NotSupportedException( SqliteStrings.InvalidMigrationOperation(operation.GetType().ShortDisplayName())); @@ -904,7 +907,10 @@ protected override void Generate( /// The command builder to use to build the commands. /// Indicates whether or not to terminate the command after generating SQL for the operation. protected override void Generate( - DropPrimaryKeyOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true) + DropPrimaryKeyOperation operation, + IModel model, + MigrationCommandListBuilder builder, + bool terminate = true) => throw new NotSupportedException( SqliteStrings.InvalidMigrationOperation(operation.GetType().ShortDisplayName())); diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteByteArrayMethodTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteByteArrayMethodTranslator.cs index 9fa34b98c29..4674327e238 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteByteArrayMethodTranslator.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteByteArrayMethodTranslator.cs @@ -38,7 +38,11 @@ public SqliteByteArrayMethodTranslator([NotNull] ISqlExpressionFactory sqlExpres /// 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 virtual SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) + public virtual SqlExpression Translate( + SqlExpression instance, + MethodInfo method, + IReadOnlyList arguments, + IDiagnosticsLogger logger) { Check.NotNull(method, nameof(method)); Check.NotNull(arguments, nameof(arguments)); diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeAddTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeAddTranslator.cs index 3f2ccfecf48..42947807fef 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeAddTranslator.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeAddTranslator.cs @@ -56,7 +56,10 @@ public SqliteDateTimeAddTranslator([NotNull] ISqlExpressionFactory sqlExpression /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) + SqlExpression instance, + MethodInfo method, + IReadOnlyList arguments, + IDiagnosticsLogger logger) { Check.NotNull(method, nameof(method)); Check.NotNull(arguments, nameof(arguments)); diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeMemberTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeMemberTranslator.cs index 87bf51dc016..366ded3b78a 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeMemberTranslator.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteDateTimeMemberTranslator.cs @@ -53,7 +53,10 @@ public SqliteDateTimeMemberTranslator([NotNull] ISqlExpressionFactory sqlExpress /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MemberInfo member, Type returnType, IDiagnosticsLogger logger) + SqlExpression instance, + MemberInfo member, + Type returnType, + IDiagnosticsLogger logger) { Check.NotNull(member, nameof(member)); Check.NotNull(returnType, nameof(returnType)); diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteMathTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteMathTranslator.cs index c44aa2a2393..2da77f952df 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteMathTranslator.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteMathTranslator.cs @@ -72,7 +72,10 @@ public SqliteMathTranslator([NotNull] ISqlExpressionFactory sqlExpressionFactory /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) + SqlExpression instance, + MethodInfo method, + IReadOnlyList arguments, + IDiagnosticsLogger logger) { Check.NotNull(method, nameof(method)); Check.NotNull(arguments, nameof(arguments)); diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteQueryTranslationPostprocessorFactory.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteQueryTranslationPostprocessorFactory.cs index cae876c1e97..a457df1e53d 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteQueryTranslationPostprocessorFactory.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteQueryTranslationPostprocessorFactory.cs @@ -3,7 +3,6 @@ using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Query; -using Microsoft.EntityFrameworkCore.Utilities; namespace Microsoft.EntityFrameworkCore.Sqlite.Query.Internal { @@ -47,4 +46,3 @@ public virtual QueryTranslationPostprocessor Create(QueryCompilationContext quer } } } - diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteQueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteQueryableMethodTranslatingExpressionVisitor.cs index ebf03004f6f..c16e581ed3a 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteQueryableMethodTranslatingExpressionVisitor.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteQueryableMethodTranslatingExpressionVisitor.cs @@ -63,7 +63,9 @@ protected override QueryableMethodTranslatingExpressionVisitor CreateSubqueryVis /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ShapedQueryExpression TranslateOrderBy( - ShapedQueryExpression source, LambdaExpression keySelector, bool ascending) + ShapedQueryExpression source, + LambdaExpression keySelector, + bool ascending) { Check.NotNull(source, nameof(source)); Check.NotNull(keySelector, nameof(keySelector)); @@ -121,7 +123,7 @@ protected override ShapedQueryExpression TranslateThenBy(ShapedQueryExpression s private static Type GetProviderType(SqlExpression expression) => expression.TypeMapping?.Converter?.ProviderClrType - ?? expression.TypeMapping?.ClrType - ?? expression.Type; + ?? expression.TypeMapping?.ClrType + ?? expression.Type; } } diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteSqlTranslatingExpressionVisitor.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteSqlTranslatingExpressionVisitor.cs index 4b72a4f0f74..cabf974bdf7 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteSqlTranslatingExpressionVisitor.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteSqlTranslatingExpressionVisitor.cs @@ -290,18 +290,22 @@ private static Type GetProviderType(SqlExpression expression) => expression == null ? null : expression.TypeMapping?.Converter?.ProviderClrType - ?? expression.TypeMapping?.ClrType - ?? expression.Type; + ?? expression.TypeMapping?.ClrType + ?? expression.Type; - private static bool AreOperandsDecimals(SqlBinaryExpression sqlExpression) => GetProviderType(sqlExpression.Left) == typeof(decimal) - && GetProviderType(sqlExpression.Right) == typeof(decimal); + private static bool AreOperandsDecimals(SqlBinaryExpression sqlExpression) + => GetProviderType(sqlExpression.Left) == typeof(decimal) + && GetProviderType(sqlExpression.Right) == typeof(decimal); - private static bool AttemptDecimalCompare(SqlBinaryExpression sqlBinary) => - AreOperandsDecimals(sqlBinary) - && new[] - { - ExpressionType.GreaterThan, ExpressionType.GreaterThanOrEqual, ExpressionType.LessThan, ExpressionType.LessThanOrEqual - }.Contains(sqlBinary.OperatorType); + private static bool AttemptDecimalCompare(SqlBinaryExpression sqlBinary) + => AreOperandsDecimals(sqlBinary) + && new[] + { + ExpressionType.GreaterThan, + ExpressionType.GreaterThanOrEqual, + ExpressionType.LessThan, + ExpressionType.LessThanOrEqual + }.Contains(sqlBinary.OperatorType); private Expression DoDecimalCompare(SqlExpression visitedExpression, ExpressionType op, SqlExpression left, SqlExpression right) { @@ -323,10 +327,10 @@ private Expression DoDecimalCompare(SqlExpression visitedExpression, ExpressionT }; } - private static bool AttemptDecimalArithmetic(SqlBinaryExpression sqlBinary) => - AreOperandsDecimals(sqlBinary) - && new[] { ExpressionType.Add, ExpressionType.Subtract, ExpressionType.Multiply, ExpressionType.Divide }.Contains( - sqlBinary.OperatorType); + private static bool AttemptDecimalArithmetic(SqlBinaryExpression sqlBinary) + => AreOperandsDecimals(sqlBinary) + && new[] { ExpressionType.Add, ExpressionType.Subtract, ExpressionType.Multiply, ExpressionType.Divide }.Contains( + sqlBinary.OperatorType); private Expression DoDecimalArithmetics(SqlExpression visitedExpression, ExpressionType op, SqlExpression left, SqlExpression right) { diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteStringLengthTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteStringLengthTranslator.cs index a16107ad30b..b8a2e1022cc 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteStringLengthTranslator.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteStringLengthTranslator.cs @@ -38,7 +38,11 @@ public SqliteStringLengthTranslator([NotNull] ISqlExpressionFactory sqlExpressio /// 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 virtual SqlExpression Translate(SqlExpression instance, MemberInfo member, Type returnType, IDiagnosticsLogger logger) + public virtual SqlExpression Translate( + SqlExpression instance, + MemberInfo member, + Type returnType, + IDiagnosticsLogger logger) { Check.NotNull(member, nameof(member)); Check.NotNull(returnType, nameof(returnType)); diff --git a/src/EFCore.Sqlite.Core/Query/Internal/SqliteStringMethodTranslator.cs b/src/EFCore.Sqlite.Core/Query/Internal/SqliteStringMethodTranslator.cs index 2c76fce0277..45aaff051a6 100644 --- a/src/EFCore.Sqlite.Core/Query/Internal/SqliteStringMethodTranslator.cs +++ b/src/EFCore.Sqlite.Core/Query/Internal/SqliteStringMethodTranslator.cs @@ -81,12 +81,12 @@ private static readonly MethodInfo _endsWithMethodInfo private static readonly MethodInfo _firstOrDefaultMethodInfoWithoutArgs = typeof(Enumerable).GetRuntimeMethods().Single( m => m.Name == nameof(Enumerable.FirstOrDefault) - && m.GetParameters().Length == 1).MakeGenericMethod(new[] { typeof(char) }); + && m.GetParameters().Length == 1).MakeGenericMethod(typeof(char)); private static readonly MethodInfo _lastOrDefaultMethodInfoWithoutArgs - = typeof(Enumerable).GetRuntimeMethods().Single( + = typeof(Enumerable).GetRuntimeMethods().Single( m => m.Name == nameof(Enumerable.LastOrDefault) - && m.GetParameters().Length == 1).MakeGenericMethod(new[] { typeof(char) }); + && m.GetParameters().Length == 1).MakeGenericMethod(typeof(char)); private readonly ISqlExpressionFactory _sqlExpressionFactory; private const char LikeEscapeChar = '\\'; @@ -109,7 +109,10 @@ public SqliteStringMethodTranslator([NotNull] ISqlExpressionFactory sqlExpressio /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) + SqlExpression instance, + MethodInfo method, + IReadOnlyList arguments, + IDiagnosticsLogger logger) { Check.NotNull(method, nameof(method)); Check.NotNull(arguments, nameof(arguments)); @@ -248,20 +251,22 @@ public virtual SqlExpression Translate( method.ReturnType); } - if (_lastOrDefaultMethodInfoWithoutArgs.Equals(method)) { var argument = arguments[0]; return _sqlExpressionFactory.Function( "substr", - new[] { argument, - _sqlExpressionFactory.Function( - "length", - new[] { argument }, - nullable: true, - argumentsPropagateNullability: new[] { true }, - typeof(int)), - _sqlExpressionFactory.Constant(1) }, + new[] + { + argument, + _sqlExpressionFactory.Function( + "length", + new[] { argument }, + nullable: true, + argumentsPropagateNullability: new[] { true }, + typeof(int)), + _sqlExpressionFactory.Constant(1) + }, nullable: true, argumentsPropagateNullability: new[] { true, true, true }, method.ReturnType); @@ -377,7 +382,8 @@ private SqlExpression TranslateStartsEndsWith(SqlExpression instance, SqlExpress } // See https://www.sqlite.org/lang_expr.html - private bool IsLikeWildChar(char c) => c == '%' || c == '_'; + private bool IsLikeWildChar(char c) + => c == '%' || c == '_'; private string EscapeLikePattern(string pattern) { @@ -433,7 +439,6 @@ private SqlExpression ProcessTrimMethod(SqlExpression instance, IReadOnlyList true).ToList(), typeof(string), diff --git a/src/EFCore.Sqlite.Core/Scaffolding/Internal/SqliteDatabaseModelFactory.cs b/src/EFCore.Sqlite.Core/Scaffolding/Internal/SqliteDatabaseModelFactory.cs index 29c626a637d..304e95f3c08 100644 --- a/src/EFCore.Sqlite.Core/Scaffolding/Internal/SqliteDatabaseModelFactory.cs +++ b/src/EFCore.Sqlite.Core/Scaffolding/Internal/SqliteDatabaseModelFactory.cs @@ -19,7 +19,6 @@ using Microsoft.EntityFrameworkCore.Sqlite.Internal; using Microsoft.EntityFrameworkCore.Storage; using Microsoft.EntityFrameworkCore.Utilities; - using static SQLitePCL.raw; namespace Microsoft.EntityFrameworkCore.Sqlite.Scaffolding.Internal @@ -252,23 +251,24 @@ private void GetColumns(DbConnection connection, DatabaseTable table) SqliteException.ThrowExceptionForRC(rc, db); } - table.Columns.Add(new DatabaseColumn - { - Table = table, - Name = columnName, - StoreType = dataType, - IsNullable = !notNull, - DefaultValueSql = defaultValue, - ValueGenerated = autoIncrement != 0 - ? ValueGenerated.OnAdd - : default(ValueGenerated?), - ComputedColumnSql = hidden != 2L && hidden != 3L - ? null - : string.Empty, - IsStored = hidden != 3L - ? default(bool?) - : true - }); + table.Columns.Add( + new DatabaseColumn + { + Table = table, + Name = columnName, + StoreType = dataType, + IsNullable = !notNull, + DefaultValueSql = defaultValue, + ValueGenerated = autoIncrement != 0 + ? ValueGenerated.OnAdd + : default(ValueGenerated?), + ComputedColumnSql = hidden != 2L && hidden != 3L + ? null + : string.Empty, + IsStored = hidden != 3L + ? default(bool?) + : true + }); } } @@ -279,7 +279,8 @@ private string FilterClrDefaults(string dataType, bool notNull, string defaultVa return null; } - if (notNull && defaultValue == "0" + if (notNull + && defaultValue == "0" && _typeMappingSource.FindMapping(dataType).ClrType.IsNumeric()) { return null; @@ -312,8 +313,7 @@ private void GetPrimaryKey(DbConnection connection, DatabaseTable table) var primaryKey = new DatabasePrimaryKey { - Table = table, - Name = name.StartsWith("sqlite_", StringComparison.Ordinal) ? string.Empty : name + Table = table, Name = name.StartsWith("sqlite_", StringComparison.Ordinal) ? string.Empty : name }; _logger.PrimaryKeyFound(name, table.Name); @@ -399,8 +399,7 @@ private void GetUniqueConstraints(DbConnection connection, DatabaseTable table) var constraintName = reader1.GetString(0); var uniqueConstraint = new DatabaseUniqueConstraint { - Table = table, - Name = constraintName.StartsWith("sqlite_", StringComparison.Ordinal) ? string.Empty : constraintName + Table = table, Name = constraintName.StartsWith("sqlite_", StringComparison.Ordinal) ? string.Empty : constraintName }; _logger.UniqueConstraintFound(constraintName, table.Name); diff --git a/src/EFCore.Sqlite.Core/Storage/Internal/SqliteDateTimeOffsetTypeMapping.cs b/src/EFCore.Sqlite.Core/Storage/Internal/SqliteDateTimeOffsetTypeMapping.cs index 4ce0a29084a..2898311b958 100644 --- a/src/EFCore.Sqlite.Core/Storage/Internal/SqliteDateTimeOffsetTypeMapping.cs +++ b/src/EFCore.Sqlite.Core/Storage/Internal/SqliteDateTimeOffsetTypeMapping.cs @@ -55,6 +55,7 @@ protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters p /// 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. /// - protected override string SqlLiteralFormatString => DateTimeOffsetFormatConst; + protected override string SqlLiteralFormatString + => DateTimeOffsetFormatConst; } } diff --git a/src/EFCore.Sqlite.Core/Storage/Internal/SqliteDateTimeTypeMapping.cs b/src/EFCore.Sqlite.Core/Storage/Internal/SqliteDateTimeTypeMapping.cs index 55750589d70..e068d9995e9 100644 --- a/src/EFCore.Sqlite.Core/Storage/Internal/SqliteDateTimeTypeMapping.cs +++ b/src/EFCore.Sqlite.Core/Storage/Internal/SqliteDateTimeTypeMapping.cs @@ -55,6 +55,7 @@ protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters p /// 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. /// - protected override string SqlLiteralFormatString => DateTimeFormatConst; + protected override string SqlLiteralFormatString + => DateTimeFormatConst; } } diff --git a/src/EFCore.Sqlite.Core/Storage/Internal/SqliteSqlGenerationHelper.cs b/src/EFCore.Sqlite.Core/Storage/Internal/SqliteSqlGenerationHelper.cs index 30c306d1643..21a3df6aa75 100644 --- a/src/EFCore.Sqlite.Core/Storage/Internal/SqliteSqlGenerationHelper.cs +++ b/src/EFCore.Sqlite.Core/Storage/Internal/SqliteSqlGenerationHelper.cs @@ -1,7 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; using System.Text; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Storage; diff --git a/src/EFCore.Sqlite.Core/Storage/Internal/SqliteStringTypeMapping.cs b/src/EFCore.Sqlite.Core/Storage/Internal/SqliteStringTypeMapping.cs index 1cbe4bd4989..0f14b9960b2 100644 --- a/src/EFCore.Sqlite.Core/Storage/Internal/SqliteStringTypeMapping.cs +++ b/src/EFCore.Sqlite.Core/Storage/Internal/SqliteStringTypeMapping.cs @@ -57,7 +57,8 @@ protected override RelationalTypeMapping Clone(RelationalTypeMappingParameters p protected override string GenerateNonNullSqlLiteral(object value) => EscapeLineBreaks(EscapeSqlLiteral((string)value)); - private static readonly char[] LineBreakChars = new char[] { '\r', '\n' }; + private static readonly char[] LineBreakChars = { '\r', '\n' }; + private static string EscapeLineBreaks(string value) { if (value == null @@ -66,9 +67,11 @@ private static string EscapeLineBreaks(string value) return $"'{value}'"; } - return ("('" + value - .Replace("\r", "' || CHAR(13) || '") - .Replace("\n", "' || CHAR(10) || '") + "')") + return ("('" + + value + .Replace("\r", "' || CHAR(13) || '") + .Replace("\n", "' || CHAR(10) || '") + + "')") .Replace("'' || ", string.Empty) .Replace(" || ''", string.Empty); } diff --git a/src/EFCore.Sqlite.Core/Update/Internal/SqliteUpdateSqlGenerator.cs b/src/EFCore.Sqlite.Core/Update/Internal/SqliteUpdateSqlGenerator.cs index 90f19705bed..b0da7be0f44 100644 --- a/src/EFCore.Sqlite.Core/Update/Internal/SqliteUpdateSqlGenerator.cs +++ b/src/EFCore.Sqlite.Core/Update/Internal/SqliteUpdateSqlGenerator.cs @@ -60,7 +60,10 @@ protected override void AppendIdentityWhereCondition(StringBuilder commandString /// doing so can result in application failures when updating to a new Entity Framework Core release. /// protected override ResultSetMapping AppendSelectAffectedCountCommand( - StringBuilder commandStringBuilder, string name, string schema, int commandPosition) + StringBuilder commandStringBuilder, + string name, + string schema, + int commandPosition) { Check.NotNull(commandStringBuilder, nameof(commandStringBuilder)); Check.NotEmpty(name, nameof(name)); diff --git a/src/EFCore.Sqlite.NTS/Infrastructure/Internal/SqliteNetTopologySuiteOptionsExtension.cs b/src/EFCore.Sqlite.NTS/Infrastructure/Internal/SqliteNetTopologySuiteOptionsExtension.cs index 52adac7f844..9a3bb47ddc3 100644 --- a/src/EFCore.Sqlite.NTS/Infrastructure/Internal/SqliteNetTopologySuiteOptionsExtension.cs +++ b/src/EFCore.Sqlite.NTS/Infrastructure/Internal/SqliteNetTopologySuiteOptionsExtension.cs @@ -70,11 +70,14 @@ public ExtensionInfo(IDbContextOptionsExtension extension) private new SqliteNetTopologySuiteOptionsExtension Extension => (SqliteNetTopologySuiteOptionsExtension)base.Extension; - public override bool IsDatabaseProvider => false; + public override bool IsDatabaseProvider + => false; - public override string LogFragment => "using NetTopologySuite "; + public override string LogFragment + => "using NetTopologySuite "; - public override long GetServiceProviderHashCode() => 0; + public override long GetServiceProviderHashCode() + => 0; public override void PopulateDebugInfo(IDictionary debugInfo) => debugInfo["NetTopologySuite"] = "1"; diff --git a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryCollectionMemberTranslator.cs b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryCollectionMemberTranslator.cs index ea1d9dff1e4..f1364b48d51 100644 --- a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryCollectionMemberTranslator.cs +++ b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryCollectionMemberTranslator.cs @@ -41,7 +41,10 @@ public SqliteGeometryCollectionMemberTranslator([NotNull] ISqlExpressionFactory /// doing so can result in application failures when updating to a new Entity Framework Core release. /// public virtual SqlExpression Translate( - SqlExpression instance, MemberInfo member, Type returnType, IDiagnosticsLogger logger) + SqlExpression instance, + MemberInfo member, + Type returnType, + IDiagnosticsLogger logger) { Check.NotNull(member, nameof(member)); Check.NotNull(returnType, nameof(returnType)); diff --git a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryCollectionMethodTranslator.cs b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryCollectionMethodTranslator.cs index 33bf41e4555..a681f67e716 100644 --- a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryCollectionMethodTranslator.cs +++ b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryCollectionMethodTranslator.cs @@ -40,7 +40,11 @@ public SqliteGeometryCollectionMethodTranslator([NotNull] ISqlExpressionFactory /// 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 virtual SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) + public virtual SqlExpression Translate( + SqlExpression instance, + MethodInfo method, + IReadOnlyList arguments, + IDiagnosticsLogger logger) { Check.NotNull(method, nameof(method)); Check.NotNull(arguments, nameof(arguments)); diff --git a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryMemberTranslator.cs b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryMemberTranslator.cs index dfda78815f2..a452b610879 100644 --- a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryMemberTranslator.cs +++ b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryMemberTranslator.cs @@ -60,7 +60,11 @@ public SqliteGeometryMemberTranslator([NotNull] ISqlExpressionFactory sqlExpress /// 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 virtual SqlExpression Translate(SqlExpression instance, MemberInfo member, Type returnType, IDiagnosticsLogger logger) + public virtual SqlExpression Translate( + SqlExpression instance, + MemberInfo member, + Type returnType, + IDiagnosticsLogger logger) { Check.NotNull(member, nameof(member)); Check.NotNull(returnType, nameof(returnType)); @@ -108,7 +112,8 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member nullable: true, argumentsPropagateNullability: new[] { true }, returnType), - new[] { + new[] + { new CaseWhenClause(_sqlExpressionFactory.Constant("POINT"), _sqlExpressionFactory.Constant("Point")), new CaseWhenClause(_sqlExpressionFactory.Constant("LINESTRING"), _sqlExpressionFactory.Constant("LineString")), new CaseWhenClause(_sqlExpressionFactory.Constant("POLYGON"), _sqlExpressionFactory.Constant("Polygon")), @@ -140,15 +145,18 @@ public virtual SqlExpression Translate(SqlExpression instance, MemberInfo member nullable: true, argumentsPropagateNullability: new[] { true }, typeof(string)), - new[] { + new[] + { new CaseWhenClause(_sqlExpressionFactory.Constant("POINT"), _sqlExpressionFactory.Constant(OgcGeometryType.Point)), new CaseWhenClause( _sqlExpressionFactory.Constant("LINESTRING"), _sqlExpressionFactory.Constant(OgcGeometryType.LineString)), - new CaseWhenClause(_sqlExpressionFactory.Constant("POLYGON"), _sqlExpressionFactory.Constant(OgcGeometryType.Polygon)), + new CaseWhenClause( + _sqlExpressionFactory.Constant("POLYGON"), _sqlExpressionFactory.Constant(OgcGeometryType.Polygon)), new CaseWhenClause( _sqlExpressionFactory.Constant("MULTIPOINT"), _sqlExpressionFactory.Constant(OgcGeometryType.MultiPoint)), new CaseWhenClause( - _sqlExpressionFactory.Constant("MULTILINESTRING"), _sqlExpressionFactory.Constant(OgcGeometryType.MultiLineString)), + _sqlExpressionFactory.Constant("MULTILINESTRING"), + _sqlExpressionFactory.Constant(OgcGeometryType.MultiLineString)), new CaseWhenClause( _sqlExpressionFactory.Constant("MULTIPOLYGON"), _sqlExpressionFactory.Constant(OgcGeometryType.MultiPolygon)), new CaseWhenClause( diff --git a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryMethodTranslator.cs b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryMethodTranslator.cs index df688019a69..32e0f2cb3d1 100644 --- a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryMethodTranslator.cs +++ b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteGeometryMethodTranslator.cs @@ -76,7 +76,11 @@ public SqliteGeometryMethodTranslator([NotNull] ISqlExpressionFactory sqlExpress /// 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 virtual SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) + public virtual SqlExpression Translate( + SqlExpression instance, + MethodInfo method, + IReadOnlyList arguments, + IDiagnosticsLogger logger) { Check.NotNull(method, nameof(method)); Check.NotNull(arguments, nameof(arguments)); @@ -97,8 +101,8 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method } return _sqlExpressionFactory.Case( - new[] - { + new[] + { new CaseWhenClause( nullCheck, _sqlExpressionFactory.Function( @@ -107,16 +111,16 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method nullable: false, finalArguments.Select(a => false), method.ReturnType)) - }, - null); + }, + null); } return _sqlExpressionFactory.Function( - functionName, - finalArguments, - nullable: true, - finalArguments.Select(a => true), - method.ReturnType); + functionName, + finalArguments, + nullable: true, + finalArguments.Select(a => true), + method.ReturnType); } if (Equals(method, _getGeometryN)) diff --git a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteLineStringMemberTranslator.cs b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteLineStringMemberTranslator.cs index d72a24876e3..d93ba9e3a85 100644 --- a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteLineStringMemberTranslator.cs +++ b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteLineStringMemberTranslator.cs @@ -50,7 +50,11 @@ public SqliteLineStringMemberTranslator([NotNull] ISqlExpressionFactory sqlExpre /// 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 virtual SqlExpression Translate(SqlExpression instance, MemberInfo member, Type returnType, IDiagnosticsLogger logger) + public virtual SqlExpression Translate( + SqlExpression instance, + MemberInfo member, + Type returnType, + IDiagnosticsLogger logger) { Check.NotNull(member, nameof(member)); Check.NotNull(returnType, nameof(returnType)); diff --git a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteLineStringMethodTranslator.cs b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteLineStringMethodTranslator.cs index 266c47c5b8e..c71296e6f89 100644 --- a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteLineStringMethodTranslator.cs +++ b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteLineStringMethodTranslator.cs @@ -42,7 +42,11 @@ public SqliteLineStringMethodTranslator([NotNull] ISqlExpressionFactory sqlExpre /// 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 virtual SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) + public virtual SqlExpression Translate( + SqlExpression instance, + MethodInfo method, + IReadOnlyList arguments, + IDiagnosticsLogger logger) { Check.NotNull(method, nameof(method)); Check.NotNull(arguments, nameof(arguments)); diff --git a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteMultiLineStringMemberTranslator.cs b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteMultiLineStringMemberTranslator.cs index bb8bd9db899..2002388cb8a 100644 --- a/src/EFCore.Sqlite.NTS/Query/Internal/SqliteMultiLineStringMemberTranslator.cs +++ b/src/EFCore.Sqlite.NTS/Query/Internal/SqliteMultiLineStringMemberTranslator.cs @@ -40,7 +40,11 @@ public SqliteMultiLineStringMemberTranslator([NotNull] ISqlExpressionFactory sql /// 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 virtual SqlExpression Translate(SqlExpression instance, MemberInfo member, Type returnType, IDiagnosticsLogger logger) + public virtual SqlExpression Translate( + SqlExpression instance, + MemberInfo member, + Type returnType, + IDiagnosticsLogger logger) { Check.NotNull(member, nameof(member)); Check.NotNull(returnType, nameof(returnType)); diff --git a/src/EFCore.Sqlite.NTS/Query/Internal/SqlitePointMemberTranslator.cs b/src/EFCore.Sqlite.NTS/Query/Internal/SqlitePointMemberTranslator.cs index fafe4886541..ff25e3f055d 100644 --- a/src/EFCore.Sqlite.NTS/Query/Internal/SqlitePointMemberTranslator.cs +++ b/src/EFCore.Sqlite.NTS/Query/Internal/SqlitePointMemberTranslator.cs @@ -48,7 +48,11 @@ public SqlitePointMemberTranslator([NotNull] ISqlExpressionFactory sqlExpression /// 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 virtual SqlExpression Translate(SqlExpression instance, MemberInfo member, Type returnType, IDiagnosticsLogger logger) + public virtual SqlExpression Translate( + SqlExpression instance, + MemberInfo member, + Type returnType, + IDiagnosticsLogger logger) { Check.NotNull(member, nameof(member)); Check.NotNull(returnType, nameof(returnType)); diff --git a/src/EFCore.Sqlite.NTS/Query/Internal/SqlitePolygonMemberTranslator.cs b/src/EFCore.Sqlite.NTS/Query/Internal/SqlitePolygonMemberTranslator.cs index 197a6101755..3efb66baf23 100644 --- a/src/EFCore.Sqlite.NTS/Query/Internal/SqlitePolygonMemberTranslator.cs +++ b/src/EFCore.Sqlite.NTS/Query/Internal/SqlitePolygonMemberTranslator.cs @@ -47,7 +47,11 @@ public SqlitePolygonMemberTranslator([NotNull] ISqlExpressionFactory sqlExpressi /// 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 virtual SqlExpression Translate(SqlExpression instance, MemberInfo member, Type returnType, IDiagnosticsLogger logger) + public virtual SqlExpression Translate( + SqlExpression instance, + MemberInfo member, + Type returnType, + IDiagnosticsLogger logger) { Check.NotNull(member, nameof(member)); Check.NotNull(returnType, nameof(returnType)); diff --git a/src/EFCore.Sqlite.NTS/Query/Internal/SqlitePolygonMethodTranslator.cs b/src/EFCore.Sqlite.NTS/Query/Internal/SqlitePolygonMethodTranslator.cs index e5011250283..16ba3050daf 100644 --- a/src/EFCore.Sqlite.NTS/Query/Internal/SqlitePolygonMethodTranslator.cs +++ b/src/EFCore.Sqlite.NTS/Query/Internal/SqlitePolygonMethodTranslator.cs @@ -42,7 +42,11 @@ public SqlitePolygonMethodTranslator([NotNull] ISqlExpressionFactory sqlExpressi /// 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 virtual SqlExpression Translate(SqlExpression instance, MethodInfo method, IReadOnlyList arguments, IDiagnosticsLogger logger) + public virtual SqlExpression Translate( + SqlExpression instance, + MethodInfo method, + IReadOnlyList arguments, + IDiagnosticsLogger logger) { Check.NotNull(method, nameof(method)); Check.NotNull(arguments, nameof(arguments)); @@ -54,7 +58,7 @@ public virtual SqlExpression Translate(SqlExpression instance, MethodInfo method "InteriorRingN", new[] { instance, _sqlExpressionFactory.Add(arguments[0], _sqlExpressionFactory.Constant(1)) }, nullable: true, - argumentsPropagateNullability: new [] { true, true }, + argumentsPropagateNullability: new[] { true, true }, method.ReturnType); } diff --git a/src/Shared/Check.cs b/src/Shared/Check.cs index 0a3ab5dc2da..d06aa69dfdb 100644 --- a/src/Shared/Check.cs +++ b/src/Shared/Check.cs @@ -112,7 +112,7 @@ public static IReadOnlyList HasNoEmptyElements( } [Conditional("DEBUG")] - public static void DebugAssert([CA.DoesNotReturnIf(false)] bool condition, string message) + public static void DebugAssert([CA.DoesNotReturnIfAttribute(false)] bool condition, string message) { if (!condition) {