Skip to content

postgre 插入或更新 相关问题 #2010

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

Open
samueltian666 opened this issue Apr 18, 2025 · 1 comment
Open

postgre 插入或更新 相关问题 #2010

samueltian666 opened this issue Apr 18, 2025 · 1 comment

Comments

@samueltian666
Copy link

问题描述及重现代码:

        public async Task Te()
    {
        try
        {
            TestClass c = new TestClass() { a = "123" };
            var data = new TestTable() { j = JObject.FromObject(c),id=1,t=c };
            //正常
            await db.InsertOrUpdate<TestTable>().SetSource(data).ExecuteAffrowsAsync();
            //System.NullReferenceException: Object reference not set to an instance of an object.
            await db.InsertOrUpdate<TestTable>().SetSource(data).ExecutePgCopyAsync();
            //有jsonmap 字段t 不加NoneParameter()报错 图1为错误信息 
            //去掉jsonmap 字段t 不管加不加NoneParameter()都报错 图2为错误信息
            await db.Insert<TestTable>()
                .NoneParameter()
                .OnConflictDoUpdate()
                .ExecuteAffrowsAsync();
        }catch (Exception e)
        {
            Debugger.Break();
        }
    }
    [Table(Name = "test")]
    public class TestTable
    {
        [Column(IsPrimary = true)]
        public int id { get; set; }
        public JObject j { get; set; }
        [JsonMap]
        public TestClass t { get; set; }
    }

    public class TestClass
    {
        public string a { get; set; }
    }
    

Image

Image

数据库版本

3.5.202

安装的Nuget包

.net framework/. net core? 及具体版本

.net9

@2881099
Copy link
Collaborator

2881099 commented Apr 19, 2025

需要观察执行的 SQL,表面看不出问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants