mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-10-15 18:55:07 +08:00
PgSql Insert useparameter bug
This commit is contained in:
@@ -33,8 +33,16 @@ namespace OrmTest
|
||||
Db.CodeFirst.InitTables<UnitTestPk>();
|
||||
Db.CodeFirst.InitTables<UnitTestPk>();
|
||||
Db.CodeFirst.InitTables<UnitTestPk>();
|
||||
}
|
||||
|
||||
Db.CodeFirst.InitTables<UnitLong1>();
|
||||
Db.Insertable(new List<UnitLong1>() { new UnitLong1() { Num = null }, new UnitLong1() { Num = null } })
|
||||
.UseParameter().ExecuteCommand();
|
||||
}
|
||||
public class UnitLong1
|
||||
{
|
||||
[SqlSugar.SugarColumn(IsNullable =true)]
|
||||
public long? Num { get; set; }
|
||||
}
|
||||
public class UnitTestPk
|
||||
{
|
||||
[SqlSugar.SugarColumn(IsPrimaryKey =true,IsIdentity =true)]
|
||||
|
@@ -149,7 +149,7 @@ namespace SqlSugar
|
||||
foreach (var gitem in groupList)
|
||||
{
|
||||
batchInsetrSql.Append("(");
|
||||
insertColumns = string.Join(",", gitem.Select(it => FormatValue(it.DbColumnName, it.Value, allParamter, itemable.InsertBuilder.Builder.SqlParameterKeyWord)));
|
||||
insertColumns = string.Join(",", gitem.Select(it => FormatValue(it.PropertyType,it.DbColumnName, it.Value, allParamter, itemable.InsertBuilder.Builder.SqlParameterKeyWord)));
|
||||
batchInsetrSql.Append(insertColumns);
|
||||
if (groupList.Last() == gitem)
|
||||
{
|
||||
@@ -161,10 +161,11 @@ namespace SqlSugar
|
||||
}
|
||||
}
|
||||
}
|
||||
private string FormatValue(string name, object value, List<SugarParameter> allParamter, string keyword)
|
||||
private string FormatValue(Type type,string name, object value, List<SugarParameter> allParamter, string keyword)
|
||||
{
|
||||
var result = keyword + name + allParamter.Count;
|
||||
allParamter.Add(new SugarParameter(result, value));
|
||||
var addParameter = new SugarParameter(result, value,type);
|
||||
allParamter.Add(addParameter);
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
Reference in New Issue
Block a user