Skip to content

Commit 19a749c

Browse files
committed
Update GenerateFluentApi for ComplexProperty.Property.Charset
1 parent 149f014 commit 19a749c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/EFCore.MySql/Design/Internal/MySqlAnnotationCodeGenerator.cs

+14
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using Microsoft.EntityFrameworkCore.Infrastructure;
1313
using Microsoft.EntityFrameworkCore.Metadata;
1414
using Microsoft.EntityFrameworkCore.Metadata.Builders;
15+
using Microsoft.EntityFrameworkCore.Metadata.Internal;
1516
using Microsoft.EntityFrameworkCore.Utilities;
1617
using Pomelo.EntityFrameworkCore.MySql.Metadata.Internal;
1718

@@ -80,6 +81,12 @@ private static readonly MethodInfo _propertyHasCharSetMethodInfo
8081
typeof(PropertyBuilder),
8182
typeof(string));
8283

84+
private static readonly MethodInfo _complexTypePropertyHasCharSetMethodInfo
85+
= typeof(MySqlComplexTypePropertyBuilderExtensions).GetRequiredRuntimeMethod(
86+
nameof(MySqlComplexTypePropertyBuilderExtensions.HasCharSet),
87+
typeof(ComplexTypePropertyBuilder),
88+
typeof(string));
89+
8390
public MySqlAnnotationCodeGenerator([JetBrains.Annotations.NotNull] AnnotationCodeGeneratorDependencies dependencies)
8491
: base(dependencies)
8592
{
@@ -262,6 +269,13 @@ protected override MethodCallCodeFragment GenerateFluentApi(IProperty property,
262269
switch (annotation.Name)
263270
{
264271
case MySqlAnnotationNames.CharSet when annotation.Value is string { Length: > 0 } charSet:
272+
if (property.DeclaringType is IComplexType)
273+
{
274+
return new MethodCallCodeFragment(
275+
_complexTypePropertyHasCharSetMethodInfo,
276+
charSet);
277+
}
278+
265279
return new MethodCallCodeFragment(
266280
_propertyHasCharSetMethodInfo,
267281
charSet);

0 commit comments

Comments
 (0)