mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-05 17:37:58 +08:00
PgSql Update List optimize
This commit is contained in:
parent
d47fcdfe90
commit
029d8adb6c
@ -24,9 +24,36 @@ namespace OrmTest
|
||||
Db.CodeFirst.InitTables<UnitArray2>();
|
||||
Db.Insertable(new UnitArray2() { MenuIds = new float[] { 1, 2 } }).ExecuteCommand();
|
||||
var x=Db.Queryable<UnitArray2>().ToList();
|
||||
Db.CodeFirst.InitTables<UnitArray311>();
|
||||
Db.Insertable(new UnitArray311()
|
||||
{
|
||||
Text=new string[] {"a","a" }
|
||||
|
||||
}).ExecuteCommand();
|
||||
Db.Updateable(new List<UnitArray311> {
|
||||
new UnitArray311()
|
||||
{
|
||||
Text = new string[] { "a12", "a2" },
|
||||
Id=1
|
||||
|
||||
},
|
||||
new UnitArray311()
|
||||
{
|
||||
Text = new string[] { "a1", "a1" },
|
||||
Id=2
|
||||
|
||||
}
|
||||
}).ExecuteCommand();
|
||||
var xxx = Db.Queryable<UnitArray311>().ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public class UnitArray311
|
||||
{
|
||||
[SugarColumn(IsArray =true,ColumnDataType ="text []" )]
|
||||
public string[] Text { get; set; }
|
||||
[SugarColumn(IsPrimaryKey =true,IsIdentity =true)]
|
||||
public int Id { get; set; }
|
||||
}
|
||||
public class UnitArray2
|
||||
{
|
||||
[SugarColumn(ColumnDataType = "real []", IsArray = true)]
|
||||
|
@ -34,7 +34,7 @@ namespace SqlSugar
|
||||
}
|
||||
}
|
||||
|
||||
public object FormatValue(object value,string name,int i)
|
||||
public object FormatValue(object value,string name,int i,DbColumnInfo columnInfo)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
@ -43,10 +43,19 @@ namespace SqlSugar
|
||||
else
|
||||
{
|
||||
var type = value.GetType();
|
||||
if (type == UtilConstants.DateType)
|
||||
if (type == UtilConstants.DateType||columnInfo.IsArray||columnInfo.IsJson)
|
||||
{
|
||||
var parameterName = this.Builder.SqlParameterKeyWord + name + i;
|
||||
this.Parameters.Add(new SugarParameter(parameterName, value));
|
||||
var paramter = new SugarParameter(parameterName, value);
|
||||
if (columnInfo.IsJson)
|
||||
{
|
||||
paramter.IsJson = true;
|
||||
}
|
||||
if (columnInfo.IsArray)
|
||||
{
|
||||
paramter.IsArray = true;
|
||||
}
|
||||
this.Parameters.Add(paramter);
|
||||
return parameterName;
|
||||
}
|
||||
else if (type == UtilConstants.ByteArrayType)
|
||||
@ -145,7 +154,7 @@ namespace SqlSugar
|
||||
dbType = "varchar";
|
||||
}
|
||||
}
|
||||
return string.Format("CAST({0} AS {1})", FormatValue(it.Value,it.DbColumnName,i), dbType);
|
||||
return string.Format("CAST({0} AS {1})", FormatValue(it.Value,it.DbColumnName,i,it), dbType);
|
||||
|
||||
})) + ")");
|
||||
++i;
|
||||
|
Loading…
Reference in New Issue
Block a user