mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +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.CodeFirst.InitTables<UnitArray2>();
|
||||||
Db.Insertable(new UnitArray2() { MenuIds = new float[] { 1, 2 } }).ExecuteCommand();
|
Db.Insertable(new UnitArray2() { MenuIds = new float[] { 1, 2 } }).ExecuteCommand();
|
||||||
var x=Db.Queryable<UnitArray2>().ToList();
|
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
|
public class UnitArray2
|
||||||
{
|
{
|
||||||
[SugarColumn(ColumnDataType = "real []", IsArray = true)]
|
[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)
|
if (value == null)
|
||||||
{
|
{
|
||||||
@ -43,10 +43,19 @@ namespace SqlSugar
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
var type = value.GetType();
|
var type = value.GetType();
|
||||||
if (type == UtilConstants.DateType)
|
if (type == UtilConstants.DateType||columnInfo.IsArray||columnInfo.IsJson)
|
||||||
{
|
{
|
||||||
var parameterName = this.Builder.SqlParameterKeyWord + name + i;
|
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;
|
return parameterName;
|
||||||
}
|
}
|
||||||
else if (type == UtilConstants.ByteArrayType)
|
else if (type == UtilConstants.ByteArrayType)
|
||||||
@ -145,7 +154,7 @@ namespace SqlSugar
|
|||||||
dbType = "varchar";
|
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;
|
++i;
|
||||||
|
Loading…
Reference in New Issue
Block a user