How can I configure Entity Framework to automatically trim values?

后端 未结 1 1249
盖世英雄少女心
盖世英雄少女心 2020-12-22 07:48

I need to make “EF Core 2.1.0” remove white space from Strings fields in queries, “HasConversion” not is not working, can you tell me why?

entity.Property(e          


        
相关标签:
1条回答
  • 2020-12-22 08:21

    That's what the varchar type is for, to trim spaces automatically, and efficiently.

    Manual trim() operations have to loop over the string every time to figure out the useful data, whereas varchar simply stores the useful length.

    In general, you'll find that EF Core has moved to remove the more useless functions in an effort to implement the useful functions in as efficient as manner as possible. Especially later EF Core versions (you're 3 versions behind).

    0 讨论(0)
提交回复
热议问题