diff --git a/src/EFCore.Cosmos/Extensions/CosmosEntityTypeBuilderExtensions.cs b/src/EFCore.Cosmos/Extensions/CosmosEntityTypeBuilderExtensions.cs index 9966b3f2271..131d5d45b91 100644 --- a/src/EFCore.Cosmos/Extensions/CosmosEntityTypeBuilderExtensions.cs +++ b/src/EFCore.Cosmos/Extensions/CosmosEntityTypeBuilderExtensions.cs @@ -261,7 +261,7 @@ public static bool CanSetPartitionKey( /// /// The builder for the entity type being configured. /// The same builder instance so that multiple calls can be chained. - public static EntityTypeBuilder UseEtagConcurrency([NotNull] this EntityTypeBuilder entityTypeBuilder) + public static EntityTypeBuilder UseETagConcurrency([NotNull] this EntityTypeBuilder entityTypeBuilder) { Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); @@ -276,11 +276,11 @@ public static EntityTypeBuilder UseEtagConcurrency([NotNull] this EntityTypeBuil /// /// The builder for the entity type being configured. /// The same builder instance so that multiple calls can be chained. - public static EntityTypeBuilder UseEtagConcurrency([NotNull] this EntityTypeBuilder entityTypeBuilder) + public static EntityTypeBuilder UseETagConcurrency([NotNull] this EntityTypeBuilder entityTypeBuilder) where TEntity : class { Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); - UseEtagConcurrency((EntityTypeBuilder)entityTypeBuilder); + UseETagConcurrency((EntityTypeBuilder)entityTypeBuilder); return entityTypeBuilder; } } diff --git a/src/EFCore.Cosmos/Extensions/CosmosPropertyBuilderExtensions.cs b/src/EFCore.Cosmos/Extensions/CosmosPropertyBuilderExtensions.cs index 4ccb130a41e..1adfcc3b6e3 100644 --- a/src/EFCore.Cosmos/Extensions/CosmosPropertyBuilderExtensions.cs +++ b/src/EFCore.Cosmos/Extensions/CosmosPropertyBuilderExtensions.cs @@ -93,7 +93,7 @@ public static bool CanSetJsonProperty( /// /// The builder for the property being configured. /// The same builder instance so that multiple calls can be chained. - public static PropertyBuilder IsEtagConcurrency([NotNull] this PropertyBuilder propertyBuilder) + public static PropertyBuilder IsETagConcurrency([NotNull] this PropertyBuilder propertyBuilder) { Check.NotNull(propertyBuilder, nameof(propertyBuilder)); propertyBuilder @@ -109,8 +109,8 @@ public static PropertyBuilder IsEtagConcurrency([NotNull] this PropertyBuilder p /// The type of the property being configured. /// The builder for the property being configured. /// The same builder instance so that multiple calls can be chained. - public static PropertyBuilder IsEtagConcurrency( + public static PropertyBuilder IsETagConcurrency( [NotNull] this PropertyBuilder propertyBuilder) - => (PropertyBuilder)IsEtagConcurrency((PropertyBuilder)propertyBuilder); + => (PropertyBuilder)IsETagConcurrency((PropertyBuilder)propertyBuilder); } } diff --git a/src/EFCore.Cosmos/Internal/CosmosModelValidator.cs b/src/EFCore.Cosmos/Internal/CosmosModelValidator.cs index 119736b53a5..13de7343c32 100644 --- a/src/EFCore.Cosmos/Internal/CosmosModelValidator.cs +++ b/src/EFCore.Cosmos/Internal/CosmosModelValidator.cs @@ -41,7 +41,7 @@ public override void Validate(IModel model, IDiagnosticsLogger @@ -181,7 +181,7 @@ protected virtual void ValidateSharedContainerCompatibility( /// 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 void ValidateOnlyEtagConcurrencyToken( + protected virtual void ValidateOnlyETagConcurrencyToken( [NotNull] IModel model, [NotNull] IDiagnosticsLogger logger) { @@ -195,7 +195,7 @@ protected virtual void ValidateOnlyEtagConcurrencyToken( if (storeName != "_etag") { throw new InvalidOperationException( - CosmosStrings.NonEtagConcurrencyToken(entityType.DisplayName(), storeName)); + CosmosStrings.NonETagConcurrencyToken(entityType.DisplayName(), storeName)); } var etagType = property.GetTypeMapping().Converter?.ProviderClrType ?? property.ClrType; diff --git a/src/EFCore.Cosmos/Metadata/Internal/CosmosAnnotationNames.cs b/src/EFCore.Cosmos/Metadata/Internal/CosmosAnnotationNames.cs index 1ec36a9b0a5..85beca4067c 100644 --- a/src/EFCore.Cosmos/Metadata/Internal/CosmosAnnotationNames.cs +++ b/src/EFCore.Cosmos/Metadata/Internal/CosmosAnnotationNames.cs @@ -49,6 +49,6 @@ public static class CosmosAnnotationNames /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// - public const string ETagName = Prefix + "EtagName"; + public const string ETagName = Prefix + "ETagName"; } } diff --git a/src/EFCore.Cosmos/Properties/CosmosStrings.Designer.cs b/src/EFCore.Cosmos/Properties/CosmosStrings.Designer.cs index c603daa504c..68e32e66bc7 100644 --- a/src/EFCore.Cosmos/Properties/CosmosStrings.Designer.cs +++ b/src/EFCore.Cosmos/Properties/CosmosStrings.Designer.cs @@ -57,11 +57,11 @@ public static string NoDiscriminatorValue([CanBeNull] object entityType, [CanBeN entityType, container); /// - /// The entity type '{entityType}' has property '{property}' as its concurrency token, but only '_etag' is supported. Consider using 'EntityTypeBuilder.UseEtagConcurrency'. + /// The entity type '{entityType}' has property '{property}' as its concurrency token, but only '_etag' is supported. Consider using 'EntityTypeBuilder.UseETagConcurrency'. /// - public static string NonEtagConcurrencyToken([CanBeNull] object entityType, [CanBeNull] object property) + public static string NonETagConcurrencyToken([CanBeNull] object entityType, [CanBeNull] object property) => string.Format( - GetString("NonEtagConcurrencyToken", nameof(entityType), nameof(property)), + GetString("NonETagConcurrencyToken", nameof(entityType), nameof(property)), entityType, property); /// diff --git a/src/EFCore.Cosmos/Properties/CosmosStrings.resx b/src/EFCore.Cosmos/Properties/CosmosStrings.resx index c31083030a4..08a70ba211c 100644 --- a/src/EFCore.Cosmos/Properties/CosmosStrings.resx +++ b/src/EFCore.Cosmos/Properties/CosmosStrings.resx @@ -1,17 +1,17 @@  - @@ -132,8 +132,8 @@ The entity type '{entityType}' is sharing the container '{container}' with other types, but does not have a discriminator value configured. - - The entity type '{entityType}' has property '{property}' as its concurrency token, but only '_etag' is supported. Consider using 'EntityTypeBuilder.UseEtagConcurrency'. + + The entity type '{entityType}' has property '{property}' as its concurrency token, but only '_etag' is supported. Consider using 'EntityTypeBuilder.UseETagConcurrency'. The entity type '{entityType}' does not have a partition key set, but it is mapped to the container '{container}' shared by entity types with partition keys. diff --git a/src/EFCore.InMemory/Query/Internal/InMemoryQueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore.InMemory/Query/Internal/InMemoryQueryableMethodTranslatingExpressionVisitor.cs index d5cc97bb56c..fcceb5f806a 100644 --- a/src/EFCore.InMemory/Query/Internal/InMemoryQueryableMethodTranslatingExpressionVisitor.cs +++ b/src/EFCore.InMemory/Query/Internal/InMemoryQueryableMethodTranslatingExpressionVisitor.cs @@ -1099,12 +1099,12 @@ private Expression TryExpand(Expression source, MemberIdentity member) .Select(p => p.ClrType) .Any(t => t.IsNullableType()); - var outerKey = entityShaperExpression.CreateKeyValueReadExpression( + var outerKey = entityShaperExpression.CreateKeyValuesExpression( navigation.IsOnDependent ? foreignKey.Properties : foreignKey.PrincipalKey.Properties, makeNullable); - var innerKey = innerShapedQuery.ShaperExpression.CreateKeyValueReadExpression( + var innerKey = innerShapedQuery.ShaperExpression.CreateKeyValuesExpression( navigation.IsOnDependent ? foreignKey.PrincipalKey.Properties : foreignKey.Properties, @@ -1147,12 +1147,12 @@ ProjectionBindingExpression projectionBindingExpression .Select(p => p.ClrType) .Any(t => t.IsNullableType()); - var outerKey = entityShaperExpression.CreateKeyValueReadExpression( + var outerKey = entityShaperExpression.CreateKeyValuesExpression( navigation.IsOnDependent ? foreignKey.Properties : foreignKey.PrincipalKey.Properties, makeNullable); - var innerKey = innerShapedQuery.ShaperExpression.CreateKeyValueReadExpression( + var innerKey = innerShapedQuery.ShaperExpression.CreateKeyValuesExpression( navigation.IsOnDependent ? foreignKey.PrincipalKey.Properties : foreignKey.Properties, diff --git a/src/EFCore.Relational/Extensions/RelationalPropertyExtensions.cs b/src/EFCore.Relational/Extensions/RelationalPropertyExtensions.cs index e5f525a8734..28bab2f8db6 100644 --- a/src/EFCore.Relational/Extensions/RelationalPropertyExtensions.cs +++ b/src/EFCore.Relational/Extensions/RelationalPropertyExtensions.cs @@ -295,16 +295,6 @@ public static IEnumerable GetTableColumnMappings([NotNull] this (IEnumerable)property[RelationalAnnotationNames.TableColumnMappings] ?? Enumerable.Empty(); - /// - /// Returns the view or table columns to which the property is mapped. - /// - /// The property. - /// The view or table columns to which the property is mapped. - public static IEnumerable GetViewOrTableColumnMappings([NotNull] this IProperty property) => - (IEnumerable)(property[RelationalAnnotationNames.ViewColumnMappings] - ?? property[RelationalAnnotationNames.TableColumnMappings]) - ?? Enumerable.Empty(); - /// /// Returns the view columns to which the property is mapped. /// diff --git a/src/EFCore.Relational/Metadata/IColumnBase.cs b/src/EFCore.Relational/Metadata/IColumnBase.cs index 3c6dde37cdf..6473a857f9e 100644 --- a/src/EFCore.Relational/Metadata/IColumnBase.cs +++ b/src/EFCore.Relational/Metadata/IColumnBase.cs @@ -19,7 +19,7 @@ public interface IColumnBase : IAnnotatable /// /// Gets the column type. /// - string Type { get; } + string StoreType { get; } /// /// Gets the value indicating whether the column can contain NULL. diff --git a/src/EFCore.Relational/Metadata/Internal/Column.cs b/src/EFCore.Relational/Metadata/Internal/Column.cs index 854969d3bb5..94be55428ed 100644 --- a/src/EFCore.Relational/Metadata/Internal/Column.cs +++ b/src/EFCore.Relational/Metadata/Internal/Column.cs @@ -26,7 +26,7 @@ public class Column : Annotatable, IColumn public Column([NotNull] string name, [CanBeNull] string type, [NotNull] Table table) { Name = name; - Type = type; + StoreType = type; Table = table; } @@ -37,7 +37,7 @@ public Column([NotNull] string name, [CanBeNull] string type, [NotNull] Table ta public virtual ITable Table { get; } /// - public virtual string Type { get; } + public virtual string StoreType { get; } /// public virtual bool IsNullable { get; set; } diff --git a/src/EFCore.Relational/Metadata/Internal/ColumnExtensions.cs b/src/EFCore.Relational/Metadata/Internal/ColumnExtensions.cs index e4abddedcd6..13ed33b1939 100644 --- a/src/EFCore.Relational/Metadata/Internal/ColumnExtensions.cs +++ b/src/EFCore.Relational/Metadata/Internal/ColumnExtensions.cs @@ -38,7 +38,7 @@ public static string ToDebugString( builder.Append(column.Name).Append(" ("); - builder.Append(column.Type).Append(")"); + builder.Append(column.StoreType).Append(")"); if (column.IsNullable) { diff --git a/src/EFCore.Relational/Metadata/Internal/ViewColumn.cs b/src/EFCore.Relational/Metadata/Internal/ViewColumn.cs index 456a27055c6..b4b80478d88 100644 --- a/src/EFCore.Relational/Metadata/Internal/ViewColumn.cs +++ b/src/EFCore.Relational/Metadata/Internal/ViewColumn.cs @@ -25,7 +25,7 @@ public class ViewColumn : Annotatable, IViewColumn public ViewColumn([NotNull] string name, [NotNull] string type, [NotNull] View view) { Name = name; - Type = type; + StoreType = type; View = view; } @@ -36,7 +36,7 @@ public ViewColumn([NotNull] string name, [NotNull] string type, [NotNull] View v public virtual IView View { get; } /// - public virtual string Type { get; } + public virtual string StoreType { get; } /// public virtual bool IsNullable { get; set; } diff --git a/src/EFCore.Relational/Metadata/Internal/ViewColumnExtensions.cs b/src/EFCore.Relational/Metadata/Internal/ViewColumnExtensions.cs index a6addb2d689..14404bf70ec 100644 --- a/src/EFCore.Relational/Metadata/Internal/ViewColumnExtensions.cs +++ b/src/EFCore.Relational/Metadata/Internal/ViewColumnExtensions.cs @@ -38,7 +38,7 @@ public static string ToDebugString( builder.Append(column.Name).Append(" ("); - builder.Append(column.Type).Append(")"); + builder.Append(column.StoreType).Append(")"); if (column.IsNullable) { diff --git a/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs b/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs index 006c7180c25..bd55fe2641f 100644 --- a/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs +++ b/src/EFCore.Relational/Migrations/Internal/MigrationsModelDiffer.cs @@ -982,8 +982,8 @@ protected virtual IEnumerable Diff( var sourceTypeMapping = sourceMapping.TypeMapping; var targetTypeMapping = targetMapping.TypeMapping; - var sourceColumnType = source.Type ?? sourceTypeMapping.StoreType; - var targetColumnType = target.Type ?? targetTypeMapping.StoreType; + var sourceColumnType = source.StoreType ?? sourceTypeMapping.StoreType; + var targetColumnType = target.StoreType ?? targetTypeMapping.StoreType; var sourceMigrationsAnnotations = source.GetAnnotations(); var targetMigrationsAnnotations = target.GetAnnotations(); @@ -1090,7 +1090,7 @@ private void Initialize( = (valueConverter?.ProviderClrType ?? typeMapping.ClrType).UnwrapNullableType(); - columnOperation.ColumnType = column.Type; + columnOperation.ColumnType = column.StoreType; columnOperation.MaxLength = column.MaxLength; columnOperation.Precision = column.Precision; columnOperation.Scale = column.Scale; diff --git a/src/EFCore.Relational/Migrations/MigrationsSqlGenerator.cs b/src/EFCore.Relational/Migrations/MigrationsSqlGenerator.cs index 6fe5b5884d0..8f4afafc211 100644 --- a/src/EFCore.Relational/Migrations/MigrationsSqlGenerator.cs +++ b/src/EFCore.Relational/Migrations/MigrationsSqlGenerator.cs @@ -1433,7 +1433,7 @@ protected virtual string GetColumnType( && operation.IsFixedLength == column.IsFixedLength && operation.IsRowVersion == column.IsRowVersion) { - return column.Type; + return column.StoreType; } keyOrIndex = table.UniqueConstraints.Any(u => u.Columns.Contains(column)) diff --git a/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs b/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs index a0b17ff3ef5..7044c159cd2 100644 --- a/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs +++ b/src/EFCore.Relational/Query/RelationalQueryableMethodTranslatingExpressionVisitor.cs @@ -1184,12 +1184,12 @@ private Expression TryExpand(Expression source, MemberIdentity member) var innerSequenceType = innerShapedQuery.Type.TryGetSequenceType(); var correlationPredicateParameter = Expression.Parameter(innerSequenceType); - var outerKey = entityShaperExpression.CreateKeyValueReadExpression( + var outerKey = entityShaperExpression.CreateKeyValuesExpression( navigation.IsOnDependent ? foreignKey.Properties : foreignKey.PrincipalKey.Properties, makeNullable); - var innerKey = correlationPredicateParameter.CreateKeyValueReadExpression( + var innerKey = correlationPredicateParameter.CreateKeyValuesExpression( navigation.IsOnDependent ? foreignKey.PrincipalKey.Properties : foreignKey.Properties, @@ -1245,12 +1245,12 @@ private Expression TryExpand(Expression source, MemberIdentity member) .Select(p => p.ClrType) .Any(t => t.IsNullableType()); - var outerKey = entityShaperExpression.CreateKeyValueReadExpression( + var outerKey = entityShaperExpression.CreateKeyValuesExpression( navigation.IsOnDependent ? foreignKey.Properties : foreignKey.PrincipalKey.Properties, makeNullable); - var innerKey = innerShapedQuery.ShaperExpression.CreateKeyValueReadExpression( + var innerKey = innerShapedQuery.ShaperExpression.CreateKeyValuesExpression( navigation.IsOnDependent ? foreignKey.PrincipalKey.Properties : foreignKey.Properties, diff --git a/src/EFCore.Sqlite.Core/Metadata/Internal/SqliteAnnotationProvider.cs b/src/EFCore.Sqlite.Core/Metadata/Internal/SqliteAnnotationProvider.cs index dd7617d5324..a03c4549fea 100644 --- a/src/EFCore.Sqlite.Core/Metadata/Internal/SqliteAnnotationProvider.cs +++ b/src/EFCore.Sqlite.Core/Metadata/Internal/SqliteAnnotationProvider.cs @@ -47,7 +47,7 @@ public SqliteAnnotationProvider([NotNull] RelationalAnnotationProviderDependenci public override IEnumerable For(IRelationalModel model) { if (model.Tables.SelectMany(t => t.Columns).Any( - c => SqliteTypeMappingSource.IsSpatialiteType(c.Type))) + c => SqliteTypeMappingSource.IsSpatialiteType(c.StoreType))) { yield return new Annotation(SqliteAnnotationNames.InitSpatialMetaData, true); } diff --git a/src/EFCore/DbContext.cs b/src/EFCore/DbContext.cs index 6302012d69f..a5498e952a9 100644 --- a/src/EFCore/DbContext.cs +++ b/src/EFCore/DbContext.cs @@ -247,7 +247,7 @@ object IDbSetCache.GetOrAddSet(IDbSetSource source, Type type) /// 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. /// - object IDbSetCache.GetOrAddSet(IDbSetSource source, string name, Type type) + object IDbSetCache.GetOrAddSet(IDbSetSource source, string entityTypeName, Type type) { CheckDisposed(); @@ -256,10 +256,10 @@ object IDbSetCache.GetOrAddSet(IDbSetSource source, string name, Type type) _sets = new Dictionary<(Type Type, string Name), object>(); } - if (!_sets.TryGetValue((type, name), out var set)) + if (!_sets.TryGetValue((type, entityTypeName), out var set)) { - set = source.Create(this, name, type); - _sets[(type, name)] = set; + set = source.Create(this, entityTypeName, type); + _sets[(type, entityTypeName)] = set; } return set; diff --git a/src/EFCore/Infrastructure/ExpressionExtensions.cs b/src/EFCore/Infrastructure/ExpressionExtensions.cs index 866bf20326c..de1b818ba9a 100644 --- a/src/EFCore/Infrastructure/ExpressionExtensions.cs +++ b/src/EFCore/Infrastructure/ExpressionExtensions.cs @@ -287,7 +287,7 @@ private static TValue ValueBufferTryReadValue( /// The list of properties to use to generate key values. /// A value indicating if the key values should be read nullable. /// An expression to read the key values. - public static Expression CreateKeyValueReadExpression( + public static Expression CreateKeyValuesExpression( [NotNull] this Expression target, [NotNull] IReadOnlyList properties, bool makeNullable = false) diff --git a/src/EFCore/Infrastructure/TypeExtensions.cs b/src/EFCore/Infrastructure/TypeExtensions.cs index 55a5960eaca..8b19379fce5 100644 --- a/src/EFCore/Infrastructure/TypeExtensions.cs +++ b/src/EFCore/Infrastructure/TypeExtensions.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Linq; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Internal; @@ -36,23 +35,5 @@ public static class TypeExtensions /// The human-readable name. public static string ShortDisplayName([NotNull] this Type type) => type.DisplayName(fullName: false); - - /// - /// Gets a value indicating whether this type is same as or implements - /// - /// The type to check. - /// - /// True if the type is same as or implements , otherwise false. - /// - public static bool IsQueryableType([NotNull] this Type type) - { - if (type.IsGenericType - && type.GetGenericTypeDefinition() == typeof(IQueryable<>)) - { - return true; - } - - return type.GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IQueryable<>)); - } } } diff --git a/src/EFCore/Internal/IDbSetCache.cs b/src/EFCore/Internal/IDbSetCache.cs index 4ec9c0134fc..909f326a2a6 100644 --- a/src/EFCore/Internal/IDbSetCache.cs +++ b/src/EFCore/Internal/IDbSetCache.cs @@ -28,6 +28,6 @@ public interface IDbSetCache /// 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. /// - object GetOrAddSet([NotNull] IDbSetSource source, [NotNull] string name, [NotNull] Type type); + object GetOrAddSet([NotNull] IDbSetSource source, [NotNull] string entityTypeName, [NotNull] Type type); } } diff --git a/src/EFCore/Metadata/IConventionPropertyBase.cs b/src/EFCore/Metadata/IConventionPropertyBase.cs index 31c73461dd2..d94c687edc2 100644 --- a/src/EFCore/Metadata/IConventionPropertyBase.cs +++ b/src/EFCore/Metadata/IConventionPropertyBase.cs @@ -66,9 +66,9 @@ public interface IConventionPropertyBase : IPropertyBase, IConventionAnnotatable /// The name of the field to use. /// Indicates whether the configuration was specified using a data annotation. /// The new . - FieldInfo SetFieldInfo([CanBeNull] string fieldName, bool fromDataAnnotation = false) + FieldInfo SetField([CanBeNull] string fieldName, bool fromDataAnnotation = false) => this.AsPropertyBase() - .SetFieldInfo(fieldName, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); + .SetField(fieldName, fromDataAnnotation ? ConfigurationSource.DataAnnotation : ConfigurationSource.Convention); /// /// Returns the configuration source for . diff --git a/src/EFCore/Metadata/IMutablePropertyBase.cs b/src/EFCore/Metadata/IMutablePropertyBase.cs index fb93b68b902..ac1f2d8abf5 100644 --- a/src/EFCore/Metadata/IMutablePropertyBase.cs +++ b/src/EFCore/Metadata/IMutablePropertyBase.cs @@ -47,7 +47,7 @@ public interface IMutablePropertyBase : IPropertyBase, IMutableAnnotatable /// /// /// The name of the field to use. - void SetFieldInfo([CanBeNull] string fieldName) - => this.AsPropertyBase().SetFieldInfo(fieldName, ConfigurationSource.Explicit); + void SetField([CanBeNull] string fieldName) + => this.AsPropertyBase().SetField(fieldName, ConfigurationSource.Explicit); } } diff --git a/src/EFCore/Metadata/Internal/InternalForeignKeyBuilder.cs b/src/EFCore/Metadata/Internal/InternalForeignKeyBuilder.cs index 9dc44d7f8e6..ab07940c4f7 100644 --- a/src/EFCore/Metadata/Internal/InternalForeignKeyBuilder.cs +++ b/src/EFCore/Metadata/Internal/InternalForeignKeyBuilder.cs @@ -942,7 +942,7 @@ public virtual InternalForeignKeyBuilder HasField( if (navigation.FieldInfo?.GetSimpleMemberName() == fieldName || configurationSource.Overrides(navigation.GetFieldInfoConfigurationSource())) { - navigation.SetFieldInfo(fieldName, configurationSource); + navigation.SetField(fieldName, configurationSource); return this; } @@ -2838,7 +2838,7 @@ private InternalForeignKeyBuilder GetOrCreateRelationshipBuilder( { return null; } - + // This workaround prevents the properties to be cleaned away before the new FK is created, // this should be replaced with reference counting // Issue #15898 diff --git a/src/EFCore/Metadata/Internal/InternalPropertyBaseBuilder`.cs b/src/EFCore/Metadata/Internal/InternalPropertyBaseBuilder`.cs index 331052e6085..634a64dd2e9 100644 --- a/src/EFCore/Metadata/Internal/InternalPropertyBaseBuilder`.cs +++ b/src/EFCore/Metadata/Internal/InternalPropertyBaseBuilder`.cs @@ -38,7 +38,7 @@ public virtual InternalPropertyBaseBuilder HasField([CanBeNull] s if (Metadata.FieldInfo?.GetSimpleMemberName() == fieldName || configurationSource.Overrides(Metadata.GetFieldInfoConfigurationSource())) { - Metadata.SetFieldInfo(fieldName, configurationSource); + Metadata.SetField(fieldName, configurationSource); return this; } diff --git a/src/EFCore/Metadata/Internal/InternalServicePropertyBuilder.cs b/src/EFCore/Metadata/Internal/InternalServicePropertyBuilder.cs index e03cf34e15d..a12889a4c1a 100644 --- a/src/EFCore/Metadata/Internal/InternalServicePropertyBuilder.cs +++ b/src/EFCore/Metadata/Internal/InternalServicePropertyBuilder.cs @@ -38,7 +38,7 @@ public virtual InternalServicePropertyBuilder HasField([CanBeNull] string fieldN if (Metadata.FieldInfo?.GetSimpleMemberName() == fieldName || configurationSource.Overrides(Metadata.GetFieldInfoConfigurationSource())) { - Metadata.SetFieldInfo(fieldName, configurationSource); + Metadata.SetField(fieldName, configurationSource); return this; } diff --git a/src/EFCore/Metadata/Internal/PropertyBase.cs b/src/EFCore/Metadata/Internal/PropertyBase.cs index c55495d3c9e..2c463f40d38 100644 --- a/src/EFCore/Metadata/Internal/PropertyBase.cs +++ b/src/EFCore/Metadata/Internal/PropertyBase.cs @@ -127,11 +127,11 @@ public virtual void SetConfigurationSource(ConfigurationSource configurationSour /// 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 FieldInfo SetFieldInfo([CanBeNull] string fieldName, ConfigurationSource configurationSource) + public virtual FieldInfo SetField([CanBeNull] string fieldName, ConfigurationSource configurationSource) { if (fieldName == null) { - return SetFieldInfo((FieldInfo)null, configurationSource); + return SetFieldInfo(null, configurationSource); } if (FieldInfo?.GetSimpleMemberName() == fieldName) diff --git a/src/EFCore/Query/ExpressionEqualityComparer.cs b/src/EFCore/Query/ExpressionEqualityComparer.cs index 6e8d90667fc..95ddc6a75f6 100644 --- a/src/EFCore/Query/ExpressionEqualityComparer.cs +++ b/src/EFCore/Query/ExpressionEqualityComparer.cs @@ -13,7 +13,7 @@ // ReSharper disable LoopCanBeConvertedToQuery namespace Microsoft.EntityFrameworkCore.Query { - public class ExpressionEqualityComparer : IEqualityComparer + public sealed class ExpressionEqualityComparer : IEqualityComparer { /// /// Creates a new . @@ -32,7 +32,7 @@ private ExpressionEqualityComparer() /// /// The obj to compute hash code for. /// The hash code value for . - public virtual int GetHashCode(Expression obj) + public int GetHashCode(Expression obj) { if (obj == null) { @@ -279,7 +279,7 @@ void AddMemberBindingsToHash(IReadOnlyList memberBindings) /// The left expression. /// The right expression. /// true if the expressions are equal, false otherwise. - public virtual bool Equals(Expression x, Expression y) => new ExpressionComparer().Compare(x, y); + public bool Equals(Expression x, Expression y) => new ExpressionComparer().Compare(x, y); private struct ExpressionComparer { diff --git a/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.ExpressionVisitors.cs b/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.ExpressionVisitors.cs index 9331ee7a2ac..1bba0e871ec 100644 --- a/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.ExpressionVisitors.cs +++ b/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.ExpressionVisitors.cs @@ -170,7 +170,7 @@ protected Expression ExpandNavigation( { // This is FirstOrDefault ending so we need to push down properties. var temporaryParameter = Expression.Parameter(root.Type); - var temporaryKey = temporaryParameter.CreateKeyValueReadExpression( + var temporaryKey = temporaryParameter.CreateKeyValuesExpression( navigation.IsOnDependent ? navigation.ForeignKey.Properties : navigation.ForeignKey.PrincipalKey.Properties, @@ -184,14 +184,14 @@ protected Expression ExpandNavigation( } else { - outerKey = root.CreateKeyValueReadExpression( + outerKey = root.CreateKeyValuesExpression( navigation.IsOnDependent ? navigation.ForeignKey.Properties : navigation.ForeignKey.PrincipalKey.Properties, makeNullable: true); } - var innerKey = innerParameter.CreateKeyValueReadExpression( + var innerKey = innerParameter.CreateKeyValuesExpression( navigation.IsOnDependent ? navigation.ForeignKey.PrincipalKey.Properties : navigation.ForeignKey.Properties, diff --git a/src/EFCore/Query/ReplacingExpressionVisitor.cs b/src/EFCore/Query/ReplacingExpressionVisitor.cs index c47e63f8a4b..637e2e06c4a 100644 --- a/src/EFCore/Query/ReplacingExpressionVisitor.cs +++ b/src/EFCore/Query/ReplacingExpressionVisitor.cs @@ -1,6 +1,7 @@ // 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.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Reflection; @@ -12,8 +13,8 @@ namespace Microsoft.EntityFrameworkCore.Query { public class ReplacingExpressionVisitor : ExpressionVisitor { - private readonly Expression[] _originals; - private readonly Expression[] _replacements; + private readonly IReadOnlyList _originals; + private readonly IReadOnlyList _replacements; public static Expression Replace([NotNull] Expression original, [NotNull] Expression replacement, [NotNull] Expression tree) { @@ -24,7 +25,7 @@ public static Expression Replace([NotNull] Expression original, [NotNull] Expres return new ReplacingExpressionVisitor(new[] { original }, new[] { replacement }).Visit(tree); } - public ReplacingExpressionVisitor([NotNull] Expression[] originals, [NotNull] Expression[] replacements) + public ReplacingExpressionVisitor([NotNull] IReadOnlyList originals, [NotNull] IReadOnlyList replacements) { Check.NotNull(originals, nameof(originals)); Check.NotNull(replacements, nameof(replacements)); @@ -42,7 +43,7 @@ public override Expression Visit(Expression expression) // We use two arrays rather than a dictionary because hash calculation here can be prohibitively expensive // for deep trees. Locality of reference makes arrays better for the small number of replacements anyway. - for (var i = 0; i < _originals.Length; i++) + for (var i = 0; i < _originals.Count; i++) { if (expression.Equals(_originals[i])) { diff --git a/src/Shared/SharedTypeExtensions.cs b/src/Shared/SharedTypeExtensions.cs index e845695f49c..a732bcb1acd 100644 --- a/src/Shared/SharedTypeExtensions.cs +++ b/src/Shared/SharedTypeExtensions.cs @@ -333,5 +333,16 @@ public static IEnumerable GetLoadableDefinedTypes(this Assembly assemb return ex.Types.Where(t => t != null).Select(IntrospectionExtensions.GetTypeInfo); } } + + public static bool IsQueryableType(this Type type) + { + if (type.IsGenericType + && type.GetGenericTypeDefinition() == typeof(IQueryable<>)) + { + return true; + } + + return type.GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IQueryable<>)); + } } } diff --git a/test/EFCore.Cosmos.FunctionalTests/CosmosConcurrencyTest.cs b/test/EFCore.Cosmos.FunctionalTests/CosmosConcurrencyTest.cs index 3c41a194ff7..35a5c32be5b 100644 --- a/test/EFCore.Cosmos.FunctionalTests/CosmosConcurrencyTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/CosmosConcurrencyTest.cs @@ -115,7 +115,7 @@ protected override void OnModelCreating(ModelBuilder builder) b => { b.HasKey(c => c.Id); - b.Property(c => c.ETag).IsEtagConcurrency(); + b.Property(c => c.ETag).IsETagConcurrency(); }); } } diff --git a/test/EFCore.Cosmos.Tests/Infrastructure/CosmosModelValidatorTest.cs b/test/EFCore.Cosmos.Tests/Infrastructure/CosmosModelValidatorTest.cs index de88043ec7d..0605149df00 100644 --- a/test/EFCore.Cosmos.Tests/Infrastructure/CosmosModelValidatorTest.cs +++ b/test/EFCore.Cosmos.Tests/Infrastructure/CosmosModelValidatorTest.cs @@ -149,7 +149,7 @@ public virtual void Detects_invalid_concurrency_token() .IsConcurrencyToken(); var model = modelBuilder.Model; - VerifyError(CosmosStrings.NonEtagConcurrencyToken(typeof(Customer).Name, "_not_etag"), model); + VerifyError(CosmosStrings.NonETagConcurrencyToken(typeof(Customer).Name, "_not_etag"), model); } protected override TestHelpers TestHelpers => CosmosTestHelpers.Instance; diff --git a/test/EFCore.Cosmos.Tests/Metadata/CosmosBuilderExtensionsTest.cs b/test/EFCore.Cosmos.Tests/Metadata/CosmosBuilderExtensionsTest.cs index 0e9b842250b..0d4897f7ec5 100644 --- a/test/EFCore.Cosmos.Tests/Metadata/CosmosBuilderExtensionsTest.cs +++ b/test/EFCore.Cosmos.Tests/Metadata/CosmosBuilderExtensionsTest.cs @@ -113,7 +113,7 @@ public void Default_discriminator_can_be_removed() public void Can_set_etag_concurrency_entity() { var modelBuilder = CreateConventionModelBuilder(); - modelBuilder.Entity().UseEtagConcurrency(); + modelBuilder.Entity().UseETagConcurrency(); var model = modelBuilder.Model; var etagProperty = model.FindEntityType(typeof(Customer).FullName).FindProperty("_etag"); @@ -126,7 +126,7 @@ public void Can_set_etag_concurrency_entity() public void Can_set_etag_concurrency_property() { var modelBuilder = CreateConventionModelBuilder(); - modelBuilder.Entity().Property(x => x.ETag).IsEtagConcurrency(); + modelBuilder.Entity().Property(x => x.ETag).IsETagConcurrency(); var model = modelBuilder.Model; var etagProperty = model.FindEntityType(typeof(Customer).FullName).FindProperty("ETag"); diff --git a/test/EFCore.Relational.Tests/Metadata/RelationalModelTest.cs b/test/EFCore.Relational.Tests/Metadata/RelationalModelTest.cs index a00793b83b8..60e20d2ae4b 100644 --- a/test/EFCore.Relational.Tests/Metadata/RelationalModelTest.cs +++ b/test/EFCore.Relational.Tests/Metadata/RelationalModelTest.cs @@ -104,7 +104,7 @@ private static void AssertViews(IRelationalModel model) Assert.Same(orderDateColumn, ordersView.FindColumn("OrderDateView")); Assert.Equal(new[] { orderDate, orderDetailsDate }, orderDateColumn.PropertyMappings.Select(m => m.Property)); Assert.Equal("OrderDateView", orderDateColumn.Name); - Assert.Equal("default_datetime_mapping", orderDateColumn.Type); + Assert.Equal("default_datetime_mapping", orderDateColumn.StoreType); Assert.False(orderDateColumn.IsNullable); Assert.Same(ordersView, orderDateColumn.Table); @@ -204,7 +204,7 @@ private static void AssertTables(IRelationalModel model) Assert.Same(orderDateColumn, ordersTable.FindColumn("OrderDate")); Assert.Equal(new[] { orderDate, orderDetailsDate }, orderDateColumn.PropertyMappings.Select(m => m.Property)); Assert.Equal("OrderDate", orderDateColumn.Name); - Assert.Equal("default_datetime_mapping", orderDateColumn.Type); + Assert.Equal("default_datetime_mapping", orderDateColumn.StoreType); Assert.False(orderDateColumn.IsNullable); Assert.Same(ordersTable, orderDateColumn.Table); diff --git a/test/EFCore.Specification.Tests/FieldMappingTestBase.cs b/test/EFCore.Specification.Tests/FieldMappingTestBase.cs index d294f2fd174..e6550307a43 100644 --- a/test/EFCore.Specification.Tests/FieldMappingTestBase.cs +++ b/test/EFCore.Specification.Tests/FieldMappingTestBase.cs @@ -1983,8 +1983,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con b.HasMany(e => e.Posts).WithOne(e => e.Blog).HasForeignKey(e => e.BlogId); }); - modelBuilder.Entity().Metadata.FindNavigation("Blog").SetFieldInfo("_myblog"); - modelBuilder.Entity().Metadata.FindNavigation("Posts").SetFieldInfo("_myposts"); + modelBuilder.Entity().Metadata.FindNavigation("Blog").SetField("_myblog"); + modelBuilder.Entity().Metadata.FindNavigation("Posts").SetField("_myposts"); modelBuilder.Entity().UsePropertyAccessMode(PropertyAccessMode.Field); @@ -2052,8 +2052,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con b.HasMany(e => e.Posts).WithOne(e => e.Blog).HasForeignKey(e => e.BlogId); }); - modelBuilder.Entity().Metadata.FindNavigation("Blog").SetFieldInfo("_myblog"); - modelBuilder.Entity().Metadata.FindNavigation("Posts").SetFieldInfo("_myposts"); + modelBuilder.Entity().Metadata.FindNavigation("Blog").SetField("_myblog"); + modelBuilder.Entity().Metadata.FindNavigation("Posts").SetField("_myposts"); modelBuilder.Entity( b => @@ -2089,8 +2089,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con b.HasMany(typeof(PostWriteOnlyExplicit).DisplayName(), "Posts").WithOne("Blog").HasForeignKey("BlogId"); }); - modelBuilder.Entity().Metadata.FindNavigation("Blog").SetFieldInfo("_myblog"); - modelBuilder.Entity().Metadata.FindNavigation("Posts").SetFieldInfo("_myposts"); + modelBuilder.Entity().Metadata.FindNavigation("Blog").SetField("_myblog"); + modelBuilder.Entity().Metadata.FindNavigation("Posts").SetField("_myposts"); modelBuilder.Entity( b => diff --git a/test/EFCore.Tests/ApiConsistencyTest.cs b/test/EFCore.Tests/ApiConsistencyTest.cs index e17dec6ee8d..f230f29b6ca 100644 --- a/test/EFCore.Tests/ApiConsistencyTest.cs +++ b/test/EFCore.Tests/ApiConsistencyTest.cs @@ -105,6 +105,7 @@ protected override void Initialize() public override HashSet UnmatchedMetadataMethods { get; } = new HashSet { + typeof(IConventionPropertyBase).GetMethod(nameof(IConventionPropertyBase.SetField)), typeof(IAnnotatable).GetMethod(nameof(IAnnotatable.FindAnnotation)), typeof(IAnnotatable).GetMethod(nameof(IAnnotatable.GetAnnotations)), typeof(IMutableAnnotatable).GetMethod("set_Item"), diff --git a/test/EFCore.Tests/Metadata/Conventions/BackingFieldConventionTest.cs b/test/EFCore.Tests/Metadata/Conventions/BackingFieldConventionTest.cs index 5b7cebbb4f6..7e912cfd1cb 100644 --- a/test/EFCore.Tests/Metadata/Conventions/BackingFieldConventionTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/BackingFieldConventionTest.cs @@ -219,7 +219,7 @@ public void Explicitly_set_FieldInfo_is_used() RunConvention(property); - property.SetFieldInfo("m_onTheRun"); + property.SetField("m_onTheRun"); Validate(property); @@ -234,7 +234,7 @@ public void FieldInfo_set_by_annotation_is_used() RunConvention((IMutableProperty)property); - property.SetFieldInfo("m_onTheRun", fromDataAnnotation: true); + property.SetField("m_onTheRun", fromDataAnnotation: true); Validate((IMutableProperty)property); @@ -261,7 +261,7 @@ public void Setting_field_on_indexer_property_throws() Assert.Equal( CoreStrings.BackingFieldOnIndexer("nation", entityType.DisplayName(), "Nation"), - Assert.Throws(() => property.SetFieldInfo("nation")).Message); + Assert.Throws(() => property.SetField("nation")).Message); } private void RunConvention(IMutableProperty property) diff --git a/test/EFCore.Tests/Metadata/Conventions/ConventionDispatcherTest.cs b/test/EFCore.Tests/Metadata/Conventions/ConventionDispatcherTest.cs index 33edb4a0702..11110e12509 100644 --- a/test/EFCore.Tests/Metadata/Conventions/ConventionDispatcherTest.cs +++ b/test/EFCore.Tests/Metadata/Conventions/ConventionDispatcherTest.cs @@ -3179,7 +3179,7 @@ public void OnPropertyFieldChanged_calls_conventions_in_order(bool useBuilder, b } else { - propertyBuilder.Metadata.SetFieldInfo(nameof(Order.IntField), + propertyBuilder.Metadata.SetField(nameof(Order.IntField), ConfigurationSource.Convention); } @@ -3200,7 +3200,7 @@ public void OnPropertyFieldChanged_calls_conventions_in_order(bool useBuilder, b } else { - propertyBuilder.Metadata.SetFieldInfo(nameof(Order.IntField), + propertyBuilder.Metadata.SetField(nameof(Order.IntField), ConfigurationSource.Convention); } diff --git a/test/EFCore.Tests/Metadata/Internal/EntityMaterializerSourceTest.cs b/test/EFCore.Tests/Metadata/Internal/EntityMaterializerSourceTest.cs index 117de4923ea..4d50c0c24fa 100644 --- a/test/EFCore.Tests/Metadata/Internal/EntityMaterializerSourceTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/EntityMaterializerSourceTest.cs @@ -212,11 +212,11 @@ public void Can_create_materializer_for_entity_with_auto_properties() public void Can_create_materializer_for_entity_with_fields() { var entityType = ((IMutableModel)new Model()).AddEntityType(typeof(SomeEntityWithFields)); - entityType.AddProperty(SomeEntityWithFields.EnumProperty).SetFieldInfo("_enum"); - entityType.AddProperty(SomeEntityWithFields.FooProperty).SetFieldInfo("_foo"); - entityType.AddProperty(SomeEntityWithFields.GooProperty).SetFieldInfo("_goo"); - entityType.AddProperty(SomeEntityWithFields.IdProperty).SetFieldInfo("_id"); - entityType.AddProperty(SomeEntityWithFields.MaybeEnumProperty).SetFieldInfo("_maybeEnum"); + entityType.AddProperty(SomeEntityWithFields.EnumProperty).SetField("_enum"); + entityType.AddProperty(SomeEntityWithFields.FooProperty).SetField("_foo"); + entityType.AddProperty(SomeEntityWithFields.GooProperty).SetField("_goo"); + entityType.AddProperty(SomeEntityWithFields.IdProperty).SetField("_id"); + entityType.AddProperty(SomeEntityWithFields.MaybeEnumProperty).SetField("_maybeEnum"); ((Model)entityType.Model).FinalizeModel(); var factory = GetMaterializer(new EntityMaterializerSource(new EntityMaterializerSourceDependencies()), entityType); diff --git a/test/EFCore.Tests/Metadata/Internal/EntityTypeTest.cs b/test/EFCore.Tests/Metadata/Internal/EntityTypeTest.cs index 06c84eedb66..e61f494b7cb 100644 --- a/test/EFCore.Tests/Metadata/Internal/EntityTypeTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/EntityTypeTest.cs @@ -2037,7 +2037,7 @@ public void FindProperty_return_null_when_passed_indexer_property_info() } [ConditionalFact] - public void AddIndexedProperty_throws_when_entitytype_does_not_have_indexer() + public void AddIndexerProperty_throws_when_entitytype_does_not_have_indexer() { var model = CreateModel(); var entityType = model.AddEntityType(typeof(Order)); @@ -2053,7 +2053,7 @@ public void AddIndexedProperty_throws_when_entitytype_does_not_have_indexer() } [ConditionalFact] - public void AddIndexedProperty_throws_when_entitytype_have_property_with_same_name() + public void AddIndexerProperty_throws_when_entitytype_have_property_with_same_name() { var model = CreateModel(); var entityType = model.AddEntityType(typeof(Customer)); diff --git a/test/EFCore.Tests/Metadata/Internal/InternalEntityTypeBuilderTest.cs b/test/EFCore.Tests/Metadata/Internal/InternalEntityTypeBuilderTest.cs index b1c4f937375..92596def3c6 100644 --- a/test/EFCore.Tests/Metadata/Internal/InternalEntityTypeBuilderTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/InternalEntityTypeBuilderTest.cs @@ -1427,7 +1427,7 @@ public void Can_add_indexed_property() var entityBuilder = modelBuilder.Entity(typeof(IndexedClass), ConfigurationSource.Explicit); var propertyBuilder = entityBuilder.IndexerProperty( - typeof(string), IndexedClass.IndexedPropertyName, ConfigurationSource.DataAnnotation); + typeof(string), IndexedClass.IndexerPropertyName, ConfigurationSource.DataAnnotation); Assert.NotNull(propertyBuilder); } @@ -1439,18 +1439,18 @@ public void Property_returns_same_instance_for_existing_index_property() var entityBuilder = modelBuilder.Entity(typeof(IndexedClass), ConfigurationSource.Explicit); var propertyBuilder = entityBuilder.IndexerProperty( - typeof(string), IndexedClass.IndexedPropertyName, ConfigurationSource.DataAnnotation); + typeof(string), IndexedClass.IndexerPropertyName, ConfigurationSource.DataAnnotation); Assert.NotNull(propertyBuilder); Assert.Same( propertyBuilder, - entityBuilder.Property(typeof(string), IndexedClass.IndexedPropertyName, ConfigurationSource.Convention)); + entityBuilder.Property(typeof(string), IndexedClass.IndexerPropertyName, ConfigurationSource.Convention)); Assert.Same( propertyBuilder, - entityBuilder.Property(IndexedClass.IndexedPropertyName, ConfigurationSource.Convention)); + entityBuilder.Property(IndexedClass.IndexerPropertyName, ConfigurationSource.Convention)); - Assert.Null(entityBuilder.Property(typeof(int), IndexedClass.IndexedPropertyName, ConfigurationSource.Convention)); + Assert.Null(entityBuilder.Property(typeof(int), IndexedClass.IndexerPropertyName, ConfigurationSource.Convention)); } [ConditionalFact] @@ -1460,12 +1460,12 @@ public void Property_removes_existing_index_property_for_higher_source_if_type_m var entityBuilder = modelBuilder.Entity(typeof(IndexedClass), ConfigurationSource.Explicit); var propertyBuilder = entityBuilder.IndexerProperty( - typeof(string), IndexedClass.IndexedPropertyName, ConfigurationSource.Convention); + typeof(string), IndexedClass.IndexerPropertyName, ConfigurationSource.Convention); Assert.NotNull(propertyBuilder); var replacedPropertyBuilder = entityBuilder.Property( - typeof(int), IndexedClass.IndexedPropertyName, ConfigurationSource.DataAnnotation); + typeof(int), IndexedClass.IndexerPropertyName, ConfigurationSource.DataAnnotation); Assert.NotNull(replacedPropertyBuilder); Assert.NotSame(propertyBuilder, replacedPropertyBuilder); @@ -1480,13 +1480,13 @@ public void Indexer_property_removes_existing_shadow_property_for_higher_source( var entityBuilder = modelBuilder.Entity(typeof(IndexedClass), ConfigurationSource.Explicit); var shadowPropertyBuilder = entityBuilder.Property( - typeof(int), IndexedClass.IndexedPropertyName, ConfigurationSource.Convention); + typeof(int), IndexedClass.IndexerPropertyName, ConfigurationSource.Convention); Assert.NotNull(shadowPropertyBuilder); Assert.True(shadowPropertyBuilder.Metadata.IsShadowProperty()); var replacedPropertyBuilder = entityBuilder.IndexerProperty( - typeof(string), IndexedClass.IndexedPropertyName, ConfigurationSource.DataAnnotation); + typeof(string), IndexedClass.IndexerPropertyName, ConfigurationSource.DataAnnotation); Assert.NotNull(replacedPropertyBuilder); Assert.NotSame(shadowPropertyBuilder, replacedPropertyBuilder); @@ -1501,10 +1501,10 @@ public void Indexed_property_throws_when_entityType_is_not_indexer() var entityBuilder = modelBuilder.Entity(typeof(Order), ConfigurationSource.Explicit); Assert.Equal( - CoreStrings.NonIndexerEntityType(IndexedClass.IndexedPropertyName, nameof(Order), typeof(string).ShortDisplayName()), + CoreStrings.NonIndexerEntityType(IndexedClass.IndexerPropertyName, nameof(Order), typeof(string).ShortDisplayName()), Assert.Throws( () => entityBuilder.IndexerProperty( - typeof(string), IndexedClass.IndexedPropertyName, ConfigurationSource.Convention)).Message); + typeof(string), IndexedClass.IndexerPropertyName, ConfigurationSource.Convention)).Message); } [ConditionalFact] @@ -3170,7 +3170,7 @@ private class Splod : Splow private class IndexedClass { - public static readonly string IndexedPropertyName = "Indexer"; + public static readonly string IndexerPropertyName = "Indexer"; public object this[string name] => null; } diff --git a/test/EFCore.Tests/Metadata/Internal/PropertyBaseTest.cs b/test/EFCore.Tests/Metadata/Internal/PropertyBaseTest.cs index 7ed3d36a216..c5b851f5241 100644 --- a/test/EFCore.Tests/Metadata/Internal/PropertyBaseTest.cs +++ b/test/EFCore.Tests/Metadata/Internal/PropertyBaseTest.cs @@ -737,7 +737,7 @@ private static IMutableProperty CreateProperty(string fieldName, string .Property(propertyName) .Metadata; - property.SetFieldInfo(fieldName); + property.SetField(fieldName); Assert.False(property.IsShadowProperty()); return property; @@ -755,7 +755,7 @@ private static IMutableNavigation CreateReferenceNavigation( .WithMany(); var navigation = relationship.Metadata.DependentToPrincipal; - navigation.SetFieldInfo(fieldName); + navigation.SetField(fieldName); return navigation; } @@ -772,7 +772,7 @@ private static IMutableNavigation CreateCollectionNavigation( .WithOne(); var navigation = relationship.Metadata.PrincipalToDependent; - navigation.SetFieldInfo(fieldName); + navigation.SetField(fieldName); return navigation; } @@ -908,7 +908,7 @@ public virtual void Field_only_properties_throws_when_field_cleared() Assert.Equal( CoreStrings.FieldNameMismatch(null, nameof(FieldOnly), "_foo"), - Assert.Throws(() => propertyBase.SetFieldInfo(null)).Message); + Assert.Throws(() => propertyBase.SetField(null)).Message); } [ConditionalFact] @@ -931,14 +931,14 @@ private void Properties_can_have_field_cleared_test(IMutablePropertyBase propert Assert.Null(propertyBase.FieldInfo); Assert.Same(propertyInfo, propertyBase.GetIdentifyingMemberInfo()); - propertyBase.SetFieldInfo(fieldName); + propertyBase.SetField(fieldName); Assert.Equal(fieldName, propertyBase.GetFieldName()); var fieldInfo = propertyBase.FieldInfo; Assert.Equal(fieldName, fieldInfo.Name); Assert.Same(propertyInfo ?? (MemberInfo)fieldInfo, propertyBase.GetIdentifyingMemberInfo()); - propertyBase.SetFieldInfo(null); + propertyBase.SetField(null); Assert.Null(propertyBase.GetFieldName()); Assert.Null(propertyBase.FieldInfo); @@ -966,7 +966,7 @@ public virtual void Setting_fieldInfo_for_shadow_property_throws() Assert.Equal( CoreStrings.FieldNameMismatch("_foo", nameof(FullProp), "shadow"), - Assert.Throws(() => property.SetFieldInfo("_foo")).Message); + Assert.Throws(() => property.SetField("_foo")).Message); } private class AutoProp