Skip to content
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

人大金仓数据库使用InsertOrUpdateDict出错 #1880

Open
hellosnowy opened this issue Sep 9, 2024 · 3 comments
Open

人大金仓数据库使用InsertOrUpdateDict出错 #1880

hellosnowy opened this issue Sep 9, 2024 · 3 comments

Comments

@hellosnowy
Copy link

问题描述及重现代码:

##问题描述

System.ArgumentNullException: Value cannot be null. (Parameter 'source')\r\n   at System.Linq.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)\r\n   at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source)\r\n   at FreeSql.PostgreSQL.Curd.OnConflictDoUpdate`1..ctor(IInsert`1 insert, Expression`1 columns)\r\n   at FreeSql.PostgreSQL.Curd.PostgreSQLInsertOrUpdate`1.<>c__DisplayClass1_0.<ToSql>g__getInsertSql|2(List`1 data, Boolean flagInsert, Boolean noneParameter)\r\n   at FreeSql.PostgreSQL.Curd.PostgreSQLInsertOrUpdate`1.<>c__DisplayClass1_0.<ToSql>b__0(List`1 a)\r\n   at System.Linq.Enumerable.SelectArrayIterator`2.MoveNext()\r\n   at System.String.Join(String separator, IEnumerable`1 values)\r\n   at FreeSql.PostgreSQL.Curd.PostgreSQLInsertOrUpdate`1.ToSql()\r\n   at FreeSqlGlobalExtensions.InsertOrUpdateDictImpl.ToSql()\r\n " 
// c# code

###重现代码

var dic = new Dictionary<string, object>();
dic.Add("id", 1);
dic.Add("name", "xxxx");


  IFreeSql freeSql= new FreeSql.FreeSqlBuilder()    .UseConnectionString(DataType.KingbaseES,Server=127.0.0.1;Port=54321;UID=test;PWD=111111;database=test;MAXPOOLSIZE=30)
    .UseMonitorCommand(cmd => Console.WriteLine($"{cmd.CommandText}\r\n"))//监听SQL语句
    .UseQuoteSqlName(true)
    .UseNoneCommandParameter(true)
    .Build();
var sql =freeSql.InsertOrUpdateDict(dic ).AsTable(“tb_test”).ToSql();
freeSql.InsertOrUpdateDict(dic ).AsTable(“tb_test”).ExecuteAffrows();
// c# code

数据库版本

人大金仓-v8r6

安装的Nuget包

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

.net6

尝试使用KingbaseES、PostgreSQL协议分别调用,都报上述错误,数据表名加不加模式(默认采用public)一样的问题,

@2881099
Copy link
Collaborator

2881099 commented Sep 9, 2024

主键没设置?

@2881099
Copy link
Collaborator

2881099 commented Sep 9, 2024

.WherePrimary("id")

和文档对照区别

@hellosnowy
Copy link
Author

确实是的,pgsql和金仓必须强制.WherePrimary("id"),mysql不需要设置也能pass

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