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

Trimming trailing spaces on char type #10836

Closed
amcorch opened this issue Jan 31, 2018 · 2 comments
Closed

Trimming trailing spaces on char type #10836

amcorch opened this issue Jan 31, 2018 · 2 comments

Comments

@amcorch
Copy link

amcorch commented Jan 31, 2018

Is there any sort of hook or interception where a char column can be trimmed so that the trailing spaces are removed?

I'm looking for a solution similar to this which is available in EF 6.1

Thanks

@ajcvickers
Copy link
Member

@amcorch In EF Core 2.1 a value converter can do this. Something like:

modelBuilder
    .Entity<Foo>()
    .Property(e => e.Bar)
    .HasConversion(v => v.Trim(), v => v.Trim());

This will remove any whitespace when coming out of or going into the database.

In EF Core 2.0 I don't think that there is an easy way to trim when data is coming from the database. You could override SaveChanges to trim going into the database.

@ajcvickers
Copy link
Member

Closing as duplicate of #242

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants