You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Json column has different support for Chinese in addition and editing #30315
public partial class User
{
[Key]
public Guid UserId { get; set; }
[StringLength(50)]
public string Name { get; set; }
public Address Address { get; set; }
}
public class Address
{
public string City { get; set; }
public User User { get; set; }
}
When data is added, the Chinese in Json column is escaped.
User user = new User()
{
UserId = Guid.NewGuid(),
Name = "超超",
Address = new Address()
{
City = "上海",
}
};
context.Add(user);
context.SaveChanges();
If you edit this record, the Chinese in the Json column will not be escaped.
var user = context.User.First();
user.Address.City = "北京";
context.SaveChanges();
Whether there is a parameter configuration that allows us to define whether Chinese is escaped.
Include provider and version information
EF Core version:7.02
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 7.0)
Operating system:Windows 11
IDE: Visual Studio 2022 17.5.0 Preview 6.0
Activity
roji commentedon Feb 20, 2023
This is probably a result of us handling partial updates differently than full-document updates... /cc @maumar
maumar commentedon Feb 22, 2023
we populate parameter value using the same code paths, and they are both in the same form in the parameter string:
vs
however, the output is different between JSON_VALUE and JSON_QUERY:
returns
北京whereas
returns
{"City" : "\u5317\u4EAC"}maumar commentedon Feb 22, 2023
to get consistent (escaped) behavior we can escape the escape char when generating string for single property value.
returns
\u5317\u4EACWe need provider specific ModificationCommand to do that properly, but we already need provider specific ModificationCommand for JSON on Sqlite work.
ajcvickers commentedon Feb 23, 2023
Note from triage: Try including Unicode characters directly in the string, rather than with escape sequences.
12 remaining items
Handle escaping in JSON consistently by using JSON_VALUE with JSON_MO…
Handle escaping in JSON consistently by using JSON_VALUE with JSON_MO…
Handle escaping in JSON consistently by using JSON_VALUE with JSON_MO…
Handle escaping in JSON consistently by using JSON_VALUE with JSON_MO…
Handle escaping in JSON consistently by using JSON_VALUE with JSON_MO…
[rc2] Handle escaping in JSON consistently by using JSON_VALUE with J…