dotnetcore / dotnetcore/FreeSql

PostgreSQL 无法使用json的text保存数据

Open
#2,266 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.4k
Forks
910
PR merge metrics
No merged PRs in 30d

Description

```
[Table(Name = "Work2")]
public class Work
{
[Column(IsIdentity = true, IsPrimary = true)]
public long Id { get; set; }

[JsonMap]
[Column(DbType = "text",MapType =typeof(string))]
public Dictionary Test6 { get; set; }
}
```

插入
```
var aaa = Enumerable.Range(1, 1).Select(o => new Work()
{
Id = 1,
Test6 = new Dictionary { { "key1", "value1" }, { "key2", "value2" } }
}).ToList();

db.Insert(aaa).ExecuteAffrows();
```

数据库
"Id" "Test6"
1 "System.Collections.Generic.Dictionary`2[System.String,System.String]"

Contributor guide

No contributing guide indexed for this repository

Research direction

Use the supplied Work model and db.Insert reproduction as the starting point; inspect the PostgreSQL mapping path for [JsonMap] with Column DbType="text" and MapType=typeof(string). Confirm completion by rerunning the insert and verifying that Test6 stores JSON text rather than the Dictionary type name.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, postgresql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
57/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.