/// <summary> /// Returns a value indicating whether the PostgreSQL storage parameter on the table created for this entity. /// </summary> /// <remarks> /// See https://www.postgresql.org/docs/current/static/sql-createtable.html#SQL-CREATETABLE-STORAGE-PARAMETERS /// </remarks> /// <param name="entityTypeBuilder"> The builder for the entity type being configured. </param> /// <param name="parameterName"> The name of the storage parameter. </param> /// <param name="parameterValue"> The value of the storage parameter. </param> /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param> /// <returns><c>true</c> if the mapped table can be configured as with the storage parameter.</returns> public static bool CanSetStorageParameter( [NotNull] this IConventionEntityTypeBuilder entityTypeBuilder, string parameterName, object parameterValue, bool fromDataAnnotation = false) { Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); return(entityTypeBuilder.CanSetAnnotation(NpgsqlAnnotationNames.StorageParameterPrefix + parameterName, parameterValue, fromDataAnnotation)); }
/// <summary> /// Returns a value indicating whether the view or table name can be set for this entity type /// using the specified configuration source. /// </summary> /// <param name="entityTypeBuilder"> The builder for the entity type being configured. </param> /// <param name="name"> The name of the view or table. </param> /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param> /// <returns> <see langword="true" /> if the configuration can be applied. </returns> public static bool CanSetFunction( [NotNull] this IConventionEntityTypeBuilder entityTypeBuilder, [CanBeNull] string name, bool fromDataAnnotation = false) { Check.NullButNotEmpty(name, nameof(name)); return(entityTypeBuilder.CanSetAnnotation(RelationalAnnotationNames.FunctionName, name, fromDataAnnotation)); }
/// <summary> /// Returns a value indicating whether the given in-memory query can be set from the current configuration source. /// </summary> /// <param name="entityTypeBuilder"> The builder for the entity type being configured. </param> /// <param name="query"> The query that will provide the underlying data for the keyless entity type. </param> /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param> /// <returns> <see langword="true" /> if the given in-memory query can be set. </returns> public static bool CanSetInMemoryQuery( this IConventionEntityTypeBuilder entityTypeBuilder, LambdaExpression?query, bool fromDataAnnotation = false) #pragma warning disable EF1001 // Internal EF Core API usage. #pragma warning disable CS0612 // Type or member is obsolete => entityTypeBuilder.CanSetAnnotation(CoreAnnotationNames.DefiningQuery, query, fromDataAnnotation);
/// <summary> /// Returns a value indicating whether the container that the entity type maps to can be set /// from the current configuration source /// </summary> /// <param name="entityTypeBuilder"> The builder for the entity type being configured. </param> /// <param name="name"> The name of the container. </param> /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param> /// <returns> <c>true</c> if the configuration can be applied. </returns> public static bool ForCosmosCanSetContainer( [NotNull] this IConventionEntityTypeBuilder entityTypeBuilder, [CanBeNull] string name, bool fromDataAnnotation = false) { Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); Check.NullButNotEmpty(name, nameof(name)); return(entityTypeBuilder.CanSetAnnotation(CosmosAnnotationNames.ContainerName, name, fromDataAnnotation)); }
/// <summary> /// Returns a value indicating whether a comment can be set for this entity type /// using the specified configuration source. /// </summary> /// <param name="entityTypeBuilder"> The builder for the entity type being configured. </param> /// <param name="comment"> The comment for the table. </param> /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param> /// <returns> <see langword="true" /> if the configuration can be applied. </returns> public static bool CanSetComment( [NotNull] this IConventionEntityTypeBuilder entityTypeBuilder, [CanBeNull] string comment, bool fromDataAnnotation = false) => entityTypeBuilder.CanSetAnnotation( RelationalAnnotationNames.Comment, comment, fromDataAnnotation);
/// <summary> /// Returns a value indicating whether the mapped table can have history table schema. /// </summary> /// <param name="entityTypeBuilder"> The builder for the entity type being configured. </param> /// <param name="schema"> The schema of the history table. </param> /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param> /// <returns> <see langword="true" /> if the mapped table can have history table schema. </returns> public static bool CanSetHistoryTableSchema( this IConventionEntityTypeBuilder entityTypeBuilder, string?schema, bool fromDataAnnotation = false) { Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); return(entityTypeBuilder.CanSetAnnotation(SqlServerAnnotationNames.TemporalHistoryTableSchema, schema, fromDataAnnotation)); }
/// <summary> /// Returns a value indicating whether the container that the entity type maps to can be set /// from the current configuration source /// </summary> /// <remarks> /// See <see href="https://aka.ms/efcore-docs-modeling">Modeling entity types and relationships</see>, and /// <see href="https://aka.ms/efcore-docs-cosmos">Accessing Azure Cosmos DB with EF Core</see> for more information and examples. /// </remarks> /// <param name="entityTypeBuilder">The builder for the entity type being configured.</param> /// <param name="name">The name of the container.</param> /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param> /// <returns><see langword="true" /> if the configuration can be applied.</returns> public static bool CanSetContainer( this IConventionEntityTypeBuilder entityTypeBuilder, string?name, bool fromDataAnnotation = false) { Check.NullButNotEmpty(name, nameof(name)); return(entityTypeBuilder.CanSetAnnotation(CosmosAnnotationNames.ContainerName, name, fromDataAnnotation)); }
/// <summary> /// Returns a value indicating whether the default time to live can be set /// from the current configuration source /// </summary> /// <remarks> /// See <see href="https://aka.ms/efcore-docs-modeling">Modeling entity types and relationships</see>, and /// <see href="https://aka.ms/efcore-docs-cosmos">Accessing Azure Cosmos DB with EF Core</see> for more information. /// </remarks> /// <param name="entityTypeBuilder">The builder for the entity type being configured.</param> /// <param name="seconds">The time to live.</param> /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param> /// <returns><see langword="true" /> if the configuration can be applied.</returns> public static bool CanSetDefaultTimeToLive( this IConventionEntityTypeBuilder entityTypeBuilder, int?seconds, bool fromDataAnnotation = false) { Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); return(entityTypeBuilder.CanSetAnnotation(CosmosAnnotationNames.DefaultTimeToLive, seconds, fromDataAnnotation)); }
/// <summary> /// Returns a value indicating whether the mapped table can have period end property. /// </summary> /// <param name="entityTypeBuilder"> The builder for the entity type being configured. </param> /// <param name="propertyName"> The name of the period end property. </param> /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param> /// <returns> <see langword="true" /> if the mapped table can have period end property. </returns> public static bool CanSetPeriodEnd( this IConventionEntityTypeBuilder entityTypeBuilder, string?propertyName, bool fromDataAnnotation = false) { Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); return(entityTypeBuilder.CanSetAnnotation(SqlServerAnnotationNames.TemporalPeriodEndPropertyName, propertyName, fromDataAnnotation)); }
/// <summary> /// Returns a value indicating whether the mapped table can be configured as memory-optimized. /// </summary> /// <param name="entityTypeBuilder"> The builder for the entity type being configured. </param> /// <param name="memoryOptimized"> A value indicating whether the table is memory-optimized. </param> /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param> /// <returns> <see langword="true" /> if the mapped table can be configured as memory-optimized. </returns> public static bool CanSetIsMemoryOptimized( this IConventionEntityTypeBuilder entityTypeBuilder, bool?memoryOptimized, bool fromDataAnnotation = false) { Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); return(entityTypeBuilder.CanSetAnnotation(SqlServerAnnotationNames.MemoryOptimized, memoryOptimized, fromDataAnnotation)); }
/// <summary> /// Returns a value indicating whether the schema of the view or table name can be set for this entity type /// using the specified configuration source. /// </summary> /// <param name="entityTypeBuilder"> The builder for the entity type being configured. </param> /// <param name="schema"> The schema of the view or table. </param> /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param> /// <returns> <see langword="true" /> if the configuration can be applied. </returns> public static bool CanSetSchema( [NotNull] this IConventionEntityTypeBuilder entityTypeBuilder, [CanBeNull] string schema, bool fromDataAnnotation = false) { Check.NullButNotEmpty(schema, nameof(schema)); return(entityTypeBuilder.CanSetAnnotation(RelationalAnnotationNames.Schema, schema, fromDataAnnotation)); }
/// <summary> /// Returns a value indicating whether the mapped table can be configured to use an unlogged table when targeting Npgsql. /// </summary> /// <param name="entityTypeBuilder">The builder for the entity type being configured.</param> /// <param name="unlogged">True to configure the entity to use an unlogged table; otherwise, false.</param> /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param> /// <returns> /// The same builder instance so that multiple calls can be chained. /// </returns> /// <remarks> /// See: https://www.postgresql.org/docs/current/sql-createtable.html#SQL-CREATETABLE-UNLOGGED /// </remarks> public static bool CanSetIsUnlogged( this IConventionEntityTypeBuilder entityTypeBuilder, bool unlogged = true, bool fromDataAnnotation = false) { Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); return(entityTypeBuilder.CanSetAnnotation(NpgsqlAnnotationNames.UnloggedTable, unlogged, fromDataAnnotation)); }
/// <summary> /// Returns a value indicating whether the mapped table can be configured as temporal. /// </summary> /// <param name="entityTypeBuilder"> The builder for the entity type being configured. </param> /// <param name="temporal"> A value indicating whether the table is temporal. </param> /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param> /// <returns> <see langword="true" /> if the mapped table can be configured as temporal. </returns> public static bool CanSetIsTemporal( this IConventionEntityTypeBuilder entityTypeBuilder, bool temporal = true, bool fromDataAnnotation = false) { Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); return(entityTypeBuilder.CanSetAnnotation(SqlServerAnnotationNames.IsTemporal, temporal, fromDataAnnotation)); }
/// <summary> /// Returns a value indicating whether the MySQL collation can be set on the table associated with this entity. /// </summary> /// <param name="entityTypeBuilder"> The builder for the entity type being configured. </param> /// <param name="collation"> The name of the collation. </param> /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param> /// <returns><see langword="true"/> if the mapped table can be configured with the collation.</returns> public static bool CanSetCollation( [NotNull] this IConventionEntityTypeBuilder entityTypeBuilder, [CanBeNull] string collation, bool fromDataAnnotation = false) { Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); Check.NullButNotEmpty(collation, nameof(collation)); return(entityTypeBuilder.CanSetAnnotation(RelationalAnnotationNames.Collation, collation, fromDataAnnotation)); }
/// <summary> /// Returns a value indicating whether the MySQL character set can be set on the table associated with this entity. /// </summary> /// <param name="entityTypeBuilder"> The builder for the entity type being configured. </param> /// <param name="charSet"> The name of the character set. </param> /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param> /// <returns><see langword="true"/> if the mapped table can be configured with the collation.</returns> public static bool CanSetCharSet( [NotNull] this IConventionEntityTypeBuilder entityTypeBuilder, [CanBeNull] string charSet, bool fromDataAnnotation = false) { Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); Check.NullButNotEmpty(charSet, nameof(charSet)); return(entityTypeBuilder.CanSetAnnotation(MySqlAnnotationNames.CharSet, charSet, fromDataAnnotation)); }
/// <summary> /// Returns a value indicating whether the given collation delegation modes can be set. /// </summary> /// <param name="entityTypeBuilder"> The builder for the entity type being configured. </param> /// <param name="delegationModes"> The collation delegation modes. </param> /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param> /// <returns> <see langword="true" /> if the given collation delegation modes can be set as default. </returns> public static bool CanSetCollationDelegation( [NotNull] this IConventionEntityTypeBuilder entityTypeBuilder, DelegationModes?delegationModes = null, bool fromDataAnnotation = false) { Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); Check.NullOrEnumValue(delegationModes, nameof(delegationModes)); return(entityTypeBuilder.CanSetAnnotation(MySqlAnnotationNames.CollationDelegation, delegationModes, fromDataAnnotation)); }
public static bool CanSetJsonProperty( [NotNull] this IConventionEntityTypeBuilder entityTypeBuilder, [CanBeNull] string?name, bool fromDataAnnotation = false) { Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); Check.NullButNotEmpty(name, nameof(name)); return(entityTypeBuilder.CanSetAnnotation(CosmosAnnotationNames.PropertyName, name, fromDataAnnotation)); }
/// <summary> /// Returns a value indicating whether the property that is used to store the partition key can be set /// from the current configuration source /// </summary> /// <remarks> /// See <see href="https://aka.ms/efcore-docs-modeling">Modeling entity types and relationships</see>, and /// <see href="https://aka.ms/efcore-docs-cosmos">Accessing Azure Cosmos DB with EF Core</see> for more information. /// </remarks> /// <param name="entityTypeBuilder">The builder for the entity type being configured.</param> /// <param name="name">The name of the partition key property.</param> /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param> /// <returns><see langword="true" /> if the configuration can be applied.</returns> public static bool CanSetPartitionKey( this IConventionEntityTypeBuilder entityTypeBuilder, string?name, bool fromDataAnnotation = false) { Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); Check.NullButNotEmpty(name, nameof(name)); return(entityTypeBuilder.CanSetAnnotation(CosmosAnnotationNames.PartitionKeyName, name, fromDataAnnotation)); }
/// <summary> /// Returns a value indicating whether the table options for the table associated with this entity can be set. /// </summary> /// <param name="entityTypeBuilder"> The builder for the entity type being configured. </param> /// <param name="name"> The name of the table options. </param> /// <param name="value"> The value of the table options. </param> /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param> /// <returns><see langword="true"/> if the value can be set.</returns> public static bool CanSetTableOption( [NotNull] this IConventionEntityTypeBuilder entityTypeBuilder, [CanBeNull] string name, [CanBeNull] string value, bool fromDataAnnotation = false) { Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); var options = entityTypeBuilder.Metadata.GetTableOptions(); UpdateTableOption(name, value, options); var optionsString = MySqlEntityTypeExtensions.SerializeTableOptions(options); return(entityTypeBuilder.CanSetAnnotation(MySqlAnnotationNames.StoreOptions, optionsString, fromDataAnnotation)); }
/// <summary> /// Returns a value indicating whether the default time to live can be set /// from the current configuration source /// </summary> /// <remarks> /// See <see href="https://aka.ms/efcore-docs-modeling">Modeling entity types and relationships</see>, and /// <see href="https://aka.ms/efcore-docs-cosmos">Accessing Azure Cosmos DB with EF Core</see> for more information and examples. /// </remarks> /// <param name="entityTypeBuilder">The builder for the entity type being configured.</param> /// <param name="seconds">The time to live.</param> /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param> /// <returns><see langword="true" /> if the configuration can be applied.</returns> public static bool CanSetDefaultTimeToLive( this IConventionEntityTypeBuilder entityTypeBuilder, int?seconds, bool fromDataAnnotation = false) => entityTypeBuilder.CanSetAnnotation(CosmosAnnotationNames.DefaultTimeToLive, seconds, fromDataAnnotation);
/// <summary> /// Returns a value indicating whether the mapped table can have period end property. /// </summary> /// <remarks> /// See <see href="https://aka.ms/efcore-docs-temporal">Using SQL Server temporal tables with EF Core</see> /// for more information. /// </remarks> /// <param name="entityTypeBuilder">The builder for the entity type being configured.</param> /// <param name="propertyName">The name of the period end property.</param> /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param> /// <returns><see langword="true" /> if the mapped table can have period end property.</returns> public static bool CanSetPeriodEnd( this IConventionEntityTypeBuilder entityTypeBuilder, string?propertyName, bool fromDataAnnotation = false) => entityTypeBuilder.CanSetAnnotation( SqlServerAnnotationNames.TemporalPeriodEndPropertyName, propertyName, fromDataAnnotation);
/// <summary> /// Returns a value indicating whether the mapped table can be configured as memory-optimized. /// </summary> /// <remarks> /// See <see href="https://aka.ms/efcore-docs-memory-optimized">Using SQL Server memory-optimized tables with EF Core</see> /// for more information. /// </remarks> /// <param name="entityTypeBuilder">The builder for the entity type being configured.</param> /// <param name="memoryOptimized">A value indicating whether the table is memory-optimized.</param> /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param> /// <returns><see langword="true" /> if the mapped table can be configured as memory-optimized.</returns> public static bool CanSetIsMemoryOptimized( this IConventionEntityTypeBuilder entityTypeBuilder, bool?memoryOptimized, bool fromDataAnnotation = false) => entityTypeBuilder.CanSetAnnotation(SqlServerAnnotationNames.MemoryOptimized, memoryOptimized, fromDataAnnotation);
/// <summary> /// Returns a value indicating whether the mapped table can be configured as temporal. /// </summary> /// <remarks> /// See <see href="https://aka.ms/efcore-docs-memory-optimized">Using SQL Server memory-optimized tables with EF Core</see> /// for more information. /// </remarks> /// <param name="entityTypeBuilder">The builder for the entity type being configured.</param> /// <param name="temporal">A value indicating whether the table is temporal.</param> /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param> /// <returns><see langword="true" /> if the mapped table can be configured as temporal.</returns> public static bool CanSetIsTemporal( this IConventionEntityTypeBuilder entityTypeBuilder, bool temporal = true, bool fromDataAnnotation = false) => entityTypeBuilder.CanSetAnnotation(SqlServerAnnotationNames.IsTemporal, temporal, fromDataAnnotation);
/// <summary> /// Returns a value indicating whether the mapped table can have history table schema. /// </summary> /// <remarks> /// See <see href="https://aka.ms/efcore-docs-temporal">Using SQL Server temporal tables with EF Core</see> /// for more information. /// </remarks> /// <param name="entityTypeBuilder">The builder for the entity type being configured.</param> /// <param name="schema">The schema of the history table.</param> /// <param name="fromDataAnnotation">Indicates whether the configuration was specified using a data annotation.</param> /// <returns><see langword="true" /> if the mapped table can have history table schema.</returns> public static bool CanSetHistoryTableSchema( this IConventionEntityTypeBuilder entityTypeBuilder, string?schema, bool fromDataAnnotation = false) => entityTypeBuilder.CanSetAnnotation(SqlServerAnnotationNames.TemporalHistoryTableSchema, schema, fromDataAnnotation);
/// <summary> /// Returns a value indicating whether the given defining query can be set from the current configuration source. /// </summary> /// <param name="entityTypeBuilder"> The builder for the entity type being configured. </param> /// <param name="query"> The query that will provide the underlying data for the keyless entity type. </param> /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param> /// <returns> <see langword="true" /> if the given defining query can be set. </returns> public static bool CanSetDefiningQuery( [NotNull] this IConventionEntityTypeBuilder entityTypeBuilder, [CanBeNull] LambdaExpression query, bool fromDataAnnotation = false) #pragma warning disable EF1001 // Internal EF Core API usage. => entityTypeBuilder.CanSetAnnotation(CoreAnnotationNames.DefiningQuery, query, fromDataAnnotation);
/// <summary> /// Returns a value indicating whether the table that this entity type is mapped to can be excluded from migrations /// using the specified configuration source. /// </summary> /// <param name="entityTypeBuilder"> The builder for the entity type being configured. </param> /// <param name="excludedFromMigrations"> A value indicating whether the table should be managed by migrations. </param> /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param> /// <returns> <see langword="true" /> if the configuration can be applied. </returns> public static bool CanExcludeTableFromMigrations( [NotNull] this IConventionEntityTypeBuilder entityTypeBuilder, bool?excludedFromMigrations, bool fromDataAnnotation = false) => entityTypeBuilder.CanSetAnnotation (RelationalAnnotationNames.IsTableExcludedFromMigrations, excludedFromMigrations, fromDataAnnotation);