Skip to content

Commit cf81792

Browse files
committed
Add HasCharSet method for ComplexPropertyBuilder
1 parent 19a749c commit cf81792

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

src/EFCore.MySql/Extensions/MySqlPropertyBuilderExtensions.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,24 @@ public static PropertyBuilder HasCharSet(
149149
return propertyBuilder;
150150
}
151151

152+
/// <summary>
153+
/// Configures the charset for the property's column.
154+
/// </summary>
155+
/// <param name="propertyBuilder">The builder for the property being configured.</param>
156+
/// <param name="charSet">The name of the charset to configure for the property's column.</param>
157+
/// <returns>The same builder instance so that multiple calls can be chained.</returns>
158+
public static ComplexPropertyBuilder HasCharSet(
159+
[NotNull] this ComplexPropertyBuilder propertyBuilder,
160+
string charSet)
161+
{
162+
Check.NotNull(propertyBuilder, nameof(propertyBuilder));
163+
164+
var property = propertyBuilder.Metadata;
165+
property.SetCharSet(charSet);
166+
167+
return propertyBuilder;
168+
}
169+
152170
/// <summary>
153171
/// Configures the charset for the property's column.
154172
/// </summary>
@@ -160,6 +178,17 @@ public static PropertyBuilder<TProperty> HasCharSet<TProperty>(
160178
string charSet)
161179
=> (PropertyBuilder<TProperty>)HasCharSet((PropertyBuilder)propertyBuilder, charSet);
162180

181+
/// <summary>
182+
/// Configures the charset for the property's column.
183+
/// </summary>
184+
/// <param name="propertyBuilder">The builder for the property being configured.</param>
185+
/// <param name="charSet">The name of the charset to configure for the property's column.</param>
186+
/// <returns>The same builder instance so that multiple calls can be chained.</returns>
187+
public static ComplexPropertyBuilder<TProperty> HasCharSet<TProperty>(
188+
[NotNull] this ComplexPropertyBuilder<TProperty> propertyBuilder,
189+
string charSet)
190+
=> (ComplexPropertyBuilder<TProperty>)HasCharSet((ComplexPropertyBuilder)propertyBuilder, charSet);
191+
163192
/// <summary>
164193
/// Configures the charset for the property's column.
165194
/// </summary>

src/EFCore.MySql/Extensions/MySqlPropertyExtensions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,14 @@ internal static string GetMySqlLegacyCharSet([NotNull] this IReadOnlyProperty pr
548548
public static void SetCharSet([NotNull] this IMutableProperty property, string charSet)
549549
=> property.SetOrRemoveAnnotation(MySqlAnnotationNames.CharSet, charSet);
550550

551+
/// <summary>
552+
/// Sets the name of the charset in use by the column of the property.
553+
/// </summary>
554+
/// <param name="property">The property to set the columns charset for.</param>
555+
/// <param name="charSet">The name of the charset used for the column of the property.</param>
556+
public static void SetCharSet([NotNull] this IMutableComplexProperty property, string charSet)
557+
=> property.SetOrRemoveAnnotation(MySqlAnnotationNames.CharSet, charSet);
558+
551559
/// <summary>
552560
/// Sets the name of the charset in use by the column of the property.
553561
/// </summary>

0 commit comments

Comments
 (0)