dotnetcore / dotnetcore/FreeSql
在使用JsonMap特性时,无法从数据库读取出数据
- Dominant language
- C#
- Stars
- 4.4k
- Forks
- 910
- PR merge metrics
- No merged PRs in 30d
Description
#### 问题描述及重现代码:
背景:我有一个A类,和A1类,A1类重写了tostring\equals\gethashCode作为值对象类型
在A类中有个字段,类型为List,并标注了特性[JsonMap]。
通过文档 https://freesql.net/guide/type-mapping.html 尝试对A1 CURD
我做了如下尝试
1. 数据库类型为 jsonb, C#字段不标注[Column(DbType="jsonb")] 结果无法添加
2. 数据库类型为 jsonb,C#字段标注[Column(DbType="jsonb")] 结果无法添加
3. 数据库类型为jsonb[], C#字段不标注dbtype 结果无法添加
4. 数据库类型为text,C#字段标注[Column(MapType = typeof(string))] 可以正常添加 参考了issue dotnetcore/FreeSql/issues/2060
最终代码类似如下:
```c#
// c# code
public class A
{
[Column(MapType=typeof(string))]
[JsonMap]
public List A1s{get; private set;}
}
public class A1
{
public ulong Id {get; private set;}
public int Num {get; private set;}
}
```
测试数据:仓储模式下 插入一条A并插入两条A1。
目前问题是: 在仓储模式下可以正常添加,select时获取到的数据A中 A1s为两条但是id和num均为0,与数据库数据不一致
#### 数据库版本
pgsql V16.4
#### 安装的Nuget包
FreeSql.Provider.PostgreSQL v3.5.212
#### .net framework/. net core? 及具体版本
.net 8
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.