Skip to content

Add HasCharSet method for ComplexPropertyBuilder#1984

Merged
lauxjpn merged 4 commits intoPomeloFoundation:mainfrom
trejjam:feature/complex-property-charset
Mar 18, 2025
Merged

Add HasCharSet method for ComplexPropertyBuilder#1984
lauxjpn merged 4 commits intoPomeloFoundation:mainfrom
trejjam:feature/complex-property-charset

Conversation

@trejjam
Copy link
Copy Markdown
Contributor

@trejjam trejjam commented Mar 4, 2025

Hi, this aims to fix an invalid snapshot generated when setting the charset on a ComplexProperty property.

Snapshot.cs(443,71): error CS1503: Argument 1: cannot convert from 'Microsoft.EntityFrameworkCore.Metadata.Builders.ComplexTypePropertyBuilder<string>' to 'Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder'
b.ComplexProperty<Dictionary<string, object>>("Figure", "...Entity.Figure#File", b1 =>
{
    b1.IsRequired();

    b1.Property<string>("Path")
        .IsRequired()
        .HasMaxLength(256)
        .HasColumnType("varchar(256)")
        .HasColumnName("FigurePath");

        MySqlPropertyBuilderExtensions.HasCharSet(b1.Property<string>("Path"), "utf8mb4");
});

@lauxjpn
Copy link
Copy Markdown
Collaborator

lauxjpn commented Mar 7, 2025

Yes, adding HasCharSet() extension methods for complex type properties makes sense.

A current workaround should be to just specify a collation instead of a charset (which is more precise anyway).

@lauxjpn lauxjpn self-requested a review March 7, 2025 00:25
@trejjam trejjam force-pushed the feature/complex-property-charset branch from 368f9d1 to dc482ac Compare March 7, 2025 15:11
Copy link
Copy Markdown
Collaborator

@lauxjpn lauxjpn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to the comments below, I think the ComplexTypePropertyBuilder extension methods should get their own class/file.

Comment thread src/EFCore.MySql/Extensions/MySqlPropertyBuilderExtensions.cs Outdated
Comment thread src/EFCore.MySql/Extensions/MySqlPropertyBuilderExtensions.cs Outdated
Comment thread src/EFCore.MySql/Extensions/MySqlPropertyExtensions.cs Outdated
@trejjam trejjam force-pushed the feature/complex-property-charset branch 2 times, most recently from cf81792 to 19a749c Compare March 8, 2025 19:05
@trejjam trejjam requested a review from lauxjpn March 8, 2025 19:07
Copy link
Copy Markdown
Collaborator

@lauxjpn lauxjpn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a little cleanup, otherwise it looks good!

Comment thread src/EFCore.MySql/Extensions/MySqlComplexTypePropertyBuilderExtensions.cs Outdated
Comment thread src/EFCore.MySql/Extensions/MySqlComplexTypePropertyBuilderExtensions.cs Outdated
@trejjam trejjam force-pushed the feature/complex-property-charset branch from 19a749c to 1ac8871 Compare March 11, 2025 23:26
@trejjam trejjam requested a review from lauxjpn March 11, 2025 23:26
Copy link
Copy Markdown
Collaborator

@lauxjpn lauxjpn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@lauxjpn lauxjpn added this to the 9.0.0-preview.4.efcore.9.0.0 milestone Mar 18, 2025
@lauxjpn lauxjpn merged commit 24a3b5b into PomeloFoundation:main Mar 18, 2025
19 checks passed
@lauxjpn
Copy link
Copy Markdown
Collaborator

lauxjpn commented Mar 18, 2025

@trejjam Thank you for your contribution!

@lauxjpn lauxjpn modified the milestones: 9.0.0-preview.4.efcore.9.0.0, 9.0.0-rc.1.efcore.9.0.0 Aug 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants