/// <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)); }
/// <summary> /// Returns a value indicating whether the given collation delegation modes can be set. /// </summary> /// <param name="modelBuilder"> The model builder. </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 IConventionModelBuilder modelBuilder, [CanBeNull] DelegationModes?delegationModes, bool fromDataAnnotation = false) { Check.NotNull(modelBuilder, nameof(modelBuilder)); Check.NullOrEnumValue(delegationModes, nameof(delegationModes)); return(modelBuilder.CanSetAnnotation(MySqlAnnotationNames.CollationDelegation, delegationModes, fromDataAnnotation)); }
/// <summary> /// Configures the database collation, which will be used by all columns without an explicit collation. Also finely controls /// where to recursively apply the collation and where not (including this model/database). /// </summary> /// <param name="modelBuilder"> The model builder. </param> /// <param name="collation"> The collation. </param> /// <param name="delegationModes"> /// Finely controls where to recursively apply the collation and where not (including this model/database). /// Implicitly uses <see cref="DelegationModes.ApplyToAll"/> if set to <see langword="null"/>. /// </param> /// <returns> The same builder instance so that multiple calls can be chained. </returns> public static ModelBuilder UseCollation( [NotNull] this ModelBuilder modelBuilder, string collation, DelegationModes?delegationModes) { Check.NotNull(modelBuilder, nameof(modelBuilder)); Check.NullButNotEmpty(collation, nameof(collation)); Check.NullOrEnumValue(delegationModes, nameof(delegationModes)); modelBuilder.Model.SetCollation(collation); modelBuilder.Model.SetCollationDelegation(delegationModes); return(modelBuilder); }
/// <summary> /// Sets the MySQL collation on the table associated with this entity. When you only specify the collation, MySQL implicitly sets /// the proper character set as well. /// </summary> /// <param name="entityTypeBuilder"> The builder for the entity type being configured. </param> /// <param name="collation"> The name of the collation. </param> /// <param name="delegationModes"> /// Finely controls where to recursively apply the character set and where not (including this entity/table). /// Implicitly uses <see cref="DelegationModes.ApplyToAll"/> if set to <see langword="null"/>. /// </param> /// <returns> The same builder instance so that multiple calls can be chained. </returns> public static EntityTypeBuilder UseCollation( [NotNull] this EntityTypeBuilder entityTypeBuilder, [CanBeNull] string collation, DelegationModes?delegationModes = null) { Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); Check.NullButNotEmpty(collation, nameof(collation)); Check.NullOrEnumValue(delegationModes, nameof(delegationModes)); entityTypeBuilder.Metadata.SetCollation(collation); entityTypeBuilder.Metadata.SetCollationDelegation(delegationModes); return(entityTypeBuilder); }
/// <summary> /// Sets the MySQL character set on the table associated with this entity. When you only specify the character set, MySQL implicitly /// uses its default collation. /// </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="delegationModes"> /// Finely controls where to recursively apply the character set and where not (including this entity/table). /// Implicitly uses <see cref="DelegationModes.ApplyToAll"/> if set to <see langword="null"/>. /// </param> /// <returns> The same builder instance so that multiple calls can be chained. </returns> public static EntityTypeBuilder HasCharSet( [NotNull] this EntityTypeBuilder entityTypeBuilder, [CanBeNull] string charSet, DelegationModes?delegationModes = null) { Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); Check.NullButNotEmpty(charSet, nameof(charSet)); Check.NullOrEnumValue(delegationModes, nameof(delegationModes)); entityTypeBuilder.Metadata.SetCharSet(charSet); entityTypeBuilder.Metadata.SetCharSetDelegation(delegationModes); return(entityTypeBuilder); }
/// <summary> /// Sets the default character set to use for the model/database. /// </summary> /// <param name="modelBuilder">The model builder.</param> /// <param name="charSet">The name of the character set to use.</param> /// <param name="delegationModes"> /// Finely controls where to recursively apply the character set and where not (including this model/database). /// Implicitly uses <see cref="DelegationModes.ApplyToAll"/> if set to <see langword="null"/>. /// </param> /// <returns>The same builder instance so that multiple calls can be chained.</returns> public static ModelBuilder HasCharSet( [NotNull] this ModelBuilder modelBuilder, [CanBeNull] string charSet, DelegationModes?delegationModes = null) { Check.NotNull(modelBuilder, nameof(modelBuilder)); Check.NullButNotEmpty(charSet, nameof(charSet)); Check.NullOrEnumValue(delegationModes, nameof(delegationModes)); if (delegationModes is not null && !Enum.IsDefined(typeof(DelegationModes), delegationModes)) { throw new ArgumentOutOfRangeException(nameof(delegationModes), delegationModes, null); } modelBuilder.Model.SetCharSet(charSet); modelBuilder.Model.SetCharSetDelegation(delegationModes); return(modelBuilder); }
/// <summary> /// Configures the database collation, which will be used by all columns without an explicit collation. Also finely controls /// where to recursively apply the collation and where not (including this model/database). /// </summary> /// <param name="modelBuilder"> The model builder. </param> /// <param name="collation"> The collation. </param> /// <param name="delegationModes"> /// Finely controls where to recursively apply the collation and where not (including this model/database). /// Implicitly uses <see cref="DelegationModes.ApplyToAll"/> if set to <see langword="null"/>. /// </param> /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param> /// <returns> /// The same builder instance if the configuration was applied, /// <see langword="null" /> otherwise. /// </returns> public static IConventionModelBuilder UseCollation( [NotNull] this IConventionModelBuilder modelBuilder, string collation, DelegationModes?delegationModes, bool fromDataAnnotation = false) { Check.NotNull(modelBuilder, nameof(modelBuilder)); Check.NullButNotEmpty(collation, nameof(collation)); Check.NullOrEnumValue(delegationModes, nameof(delegationModes)); if (modelBuilder.CanSetCollation(collation, fromDataAnnotation) && modelBuilder.CanSetCollationDelegation(delegationModes, fromDataAnnotation)) { modelBuilder.Metadata.SetCollation(collation, fromDataAnnotation); modelBuilder.Metadata.SetCharSetDelegation(delegationModes, fromDataAnnotation); return(modelBuilder); } return(null); }
/// <summary> /// Sets the MySQL collation on the table associated with this entity. When you only specify the collation, MySQL implicitly sets /// the proper character set as well. /// </summary> /// <param name="entityTypeBuilder"> The builder for the entity type being configured. </param> /// <param name="collation"> The name of the collation. </param> /// <param name="delegationModes"> /// Finely controls where to recursively apply the character set and where not (including this entity/table). /// Implicitly uses <see cref="DelegationModes.ApplyToAll"/> if set to <see langword="null"/>. /// </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> public static IConventionEntityTypeBuilder UseCollation( [NotNull] this IConventionEntityTypeBuilder entityTypeBuilder, [CanBeNull] string collation, DelegationModes?delegationModes = null, bool fromDataAnnotation = false) { Check.NotNull(entityTypeBuilder, nameof(entityTypeBuilder)); Check.NullButNotEmpty(collation, nameof(collation)); Check.NullOrEnumValue(delegationModes, nameof(delegationModes)); if (entityTypeBuilder.CanSetCollation(collation, fromDataAnnotation) && entityTypeBuilder.CanSetCollationDelegation(delegationModes, fromDataAnnotation)) { entityTypeBuilder.Metadata.SetCollation(collation, fromDataAnnotation); entityTypeBuilder.Metadata.SetCollationDelegation(delegationModes, fromDataAnnotation); return(entityTypeBuilder); } return(null); }
/// <summary> /// Sets the default character set to use for the model/database. /// </summary> /// <param name="modelBuilder">The model builder.</param> /// <param name="charSet">The name of the character set to use.</param> /// <param name="delegationModes"> /// Finely controls where to recursively apply the character set and where not (including this model/database). /// Implicitly uses <see cref="DelegationModes.ApplyToAll"/> if set to <see langword="null"/>. /// </param> /// <param name="fromDataAnnotation"> Indicates whether the configuration was specified using a data annotation. </param> /// <returns> /// The same builder instance if the configuration was applied, /// <see langword="null" /> otherwise. /// </returns> public static IConventionModelBuilder HasCharSet( [NotNull] this IConventionModelBuilder modelBuilder, [CanBeNull] string charSet, DelegationModes?delegationModes = null, bool fromDataAnnotation = false) { Check.NotNull(modelBuilder, nameof(modelBuilder)); Check.NullButNotEmpty(charSet, nameof(charSet)); Check.NullOrEnumValue(delegationModes, nameof(delegationModes)); if (modelBuilder.CanSetCharSet(charSet, fromDataAnnotation) && modelBuilder.CanSetCharSetDelegation(delegationModes, fromDataAnnotation)) { modelBuilder.Metadata.SetCharSet(charSet, fromDataAnnotation); modelBuilder.Metadata.SetCharSetDelegation(delegationModes, fromDataAnnotation); return(modelBuilder); } return(null); }
protected MySqlCollationAttribute(string collation, DelegationModes?delegationModes) { CollationName = collation; DelegationModes = delegationModes; }
/// <summary> /// Sets the MySQL character set on the table associated with this entity. When you only specify the character set, MySQL implicitly /// uses its default collation. /// </summary> /// <param name="entityTypeBuilder"> The builder for the entity type being configured. </param> /// <param name="charSet"> The character set. </param> /// <param name="delegationModes"> /// Finely controls where to recursively apply the character set and where not (including this entity/table). /// Implicitly uses <see cref="DelegationModes.ApplyToAll"/> if set to <see langword="null"/>. /// </param> /// <returns> The same builder instance so that multiple calls can be chained. </returns> public static EntityTypeBuilder HasCharSet( [NotNull] this EntityTypeBuilder entityTypeBuilder, [CanBeNull] CharSet charSet, DelegationModes?delegationModes = null) => entityTypeBuilder.HasCharSet(charSet?.Name, delegationModes);
/// <summary> /// Sets the MySQL character set on the table associated with this entity. When you only specify the character set, MySQL implicitly /// uses its default collation. /// </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="delegationModes"> /// Finely controls where to recursively apply the character set and where not (including this entity/table). /// Implicitly uses <see cref="DelegationModes.ApplyToAll"/> if set to <see langword="null"/>. /// </param> /// <returns> The same builder instance so that multiple calls can be chained. </returns> public static EntityTypeBuilder <TEntity> HasCharSet <TEntity>( [NotNull] this EntityTypeBuilder <TEntity> entityTypeBuilder, [CanBeNull] string charSet, DelegationModes?delegationModes = null) where TEntity : class => (EntityTypeBuilder <TEntity>)HasCharSet((EntityTypeBuilder)entityTypeBuilder, charSet, delegationModes);
/// <summary> /// Sets the MySQL collation on the table associated with this entity. When you only specify the collation, MySQL implicitly sets /// the proper character set as well. /// </summary> /// <param name="entityTypeBuilder"> The builder for the entity type being configured. </param> /// <param name="collation"> The name of the collation. </param> /// <param name="delegationModes"> /// Finely controls where to recursively apply the character set and where not (including this entity/table). /// Implicitly uses <see cref="DelegationModes.ApplyToAll"/> if set to <see langword="null"/>. /// </param> /// <returns> The same builder instance so that multiple calls can be chained. </returns> public static EntityTypeBuilder <TEntity> UseCollation <TEntity>( [NotNull] this EntityTypeBuilder <TEntity> entityTypeBuilder, [CanBeNull] string collation, DelegationModes?delegationModes = null) where TEntity : class => (EntityTypeBuilder <TEntity>)UseCollation((EntityTypeBuilder)entityTypeBuilder, collation, delegationModes);
/// <summary> /// Sets the MySQL character set on the table associated with this entity. When you only specify the character set, MySQL implicitly /// uses its default collation. /// </summary> /// <param name="entityTypeBuilder"> The builder for the entity type being configured. </param> /// <param name="charSet"> The character set. </param> /// <param name="delegationModes"> /// Finely controls where to recursively apply the character set and where not (including this entity/table). /// Implicitly uses <see cref="DelegationModes.ApplyToAll"/> if set to <see langword="null"/>. /// </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> public static IConventionEntityTypeBuilder HasCharSet( [NotNull] this IConventionEntityTypeBuilder entityTypeBuilder, [CanBeNull] CharSet charSet, DelegationModes?delegationModes = null, bool fromDataAnnotation = false) => entityTypeBuilder.HasCharSet(charSet?.Name, delegationModes, fromDataAnnotation);
/// <summary> /// Sets the MySQL character set on the table associated with this entity. When you only specify the character set, MySQL implicitly /// uses its default collation. /// </summary> /// <param name="entityTypeBuilder"> The builder for the entity type being configured. </param> /// <param name="charSet"> The character set. </param> /// <param name="delegationModes"> /// Finely controls where to recursively apply the character set and where not (including this entity/table). /// Implicitly uses <see cref="DelegationModes.ApplyToAll"/> if set to <see langword="null"/>. /// </param> /// <returns> The same builder instance so that multiple calls can be chained. </returns> public static EntityTypeBuilder <TEntity> HasCharSet <TEntity>( [NotNull] this EntityTypeBuilder <TEntity> entityTypeBuilder, [CanBeNull] CharSet charSet, DelegationModes?delegationModes = null) where TEntity : class => entityTypeBuilder.HasCharSet(charSet?.Name, delegationModes);
protected MySqlCharSetAttribute(string charSet, DelegationModes?delegationModes) { CharSetName = charSet; DelegationModes = delegationModes; }
/// <summary> /// Sets the default character set to use for the model/database. /// </summary> /// <param name="modelBuilder">The model builder.</param> /// <param name="charSet">The character set to use.</param> /// <param name="delegationModes"> /// Finely controls where to recursively apply the character set and where not (including this model/database). /// Implicitly uses <see cref="DelegationModes.ApplyToAll"/> if set to <see langword="null"/>. /// </param> /// <returns>The same builder instance so that multiple calls can be chained.</returns> public static ModelBuilder HasCharSet( [NotNull] this ModelBuilder modelBuilder, [CanBeNull] CharSet charSet, DelegationModes?delegationModes = null) => modelBuilder.HasCharSet(charSet?.Name, delegationModes);