PgSql Insert useparameter bug

This commit is contained in:
sunkaixuna
2022-02-08 11:15:43 +08:00
parent bcf1a0bb97
commit 8bc9b88425
2 changed files with 13 additions and 4 deletions

View File

@@ -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)]

View File

@@ -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