Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PropertyBuilder can have custom ValueComparer #19256

Closed
wants to merge 1 commit into from

Conversation

halllo
Copy link

@halllo halllo commented Dec 9, 2019

I have a DbContext with a conversion like this:

public void Configure(EntityTypeBuilder<CachedGroup> builder)
{
	builder.Property(e => e.Roles).HasConversion(
		x => JsonConvert.SerializeObject(x, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }),
		x => JsonConvert.DeserializeObject<IList<string>>(x, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }));
}

When the DbContext gets created, it logs the following warning:

The property '"Roles"' on entity type '"CachedUser"' is a collection or enumeration type with a value converter but with no value comparer. Set a value comparer to ensure the collection/enumeration elements are compared correctly.

Apparently there is no ValueComparer associated with this property. Only InternalPropertyBuilder allowed setting custom ValueCompareres. I though it was a good idea to allow custom ValueComparers to get rid of the mentioned warning. What do you think?

@dnfclas
Copy link

dnfclas commented Dec 9, 2019

CLA assistant check
All CLA requirements met.

@ajcvickers
Copy link
Member

Duplicate of #18643. See #17471 (comment) for how to do it before this is implemented.

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.

3 participants