-
Notifications
You must be signed in to change notification settings - Fork 861
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
JSON field ignored during load when it's an array #653
Comments
Modify Test Case: record TestClass(string Name)
{
public Guid Id { get; set; }
public TestClassTagInfo Tags { get; init; }
}
record TestClassTagInfo //Important changes
{
public string[] Tags { get; init; } = Array.Empty<string>();
}
using (var freeSql = new FreeSql.FreeSqlBuilder()
.UseConnectionString(DataType.Sqlite, "Data Source=test11.sqlite")
.UseAutoSyncStructure(true)
.UseNoneCommandParameter(true)
.UseMonitorCommand(cmd => Trace.WriteLine(cmd.CommandText))
.Build())
{
freeSql.UseJsonMap();
freeSql.CodeFirst.ConfigEntity<TestClass>(cf =>
{
cf.Property(p => p.Name).IsNullable(false);
cf.Property(p => p.Tags).JsonMap();
});
freeSql.Insert<TestClass>(
new TestClass("test 1")
{
Tags = new TestClassTagInfo { Tags = new[] { "a", "b" } },
})
.ExecuteAffrows();
var records = freeSql.Queryable<TestClass>().ToList();
} The string [] type is not supported in FreeSQL JsonMap. It is recommended to use the new type, which can be better supported. At present, there are some limitations in the use of jsonmap, and we will improve it later. thank. |
@luoyunchong This doesn't seem to be a viable solution, because the resulting JSON is different |
2881099
added a commit
that referenced
this issue
Aug 9, 2022
Problem solved, v3.2.666-preview20220809 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Test case:
The
Tags
property of the loaded records is an empty record, but the data is stored correctly. I guess that the ORM sees theTags
property as a navigation property and therefore skips the JSON deserialization.Tested with 2.0.105. The 2.3 preview throws an exception that it's unable to cast from
string[]
tostring
.The text was updated successfully, but these errors were encountered: