mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-20 18:48:09 +08:00
Update Sqlite
This commit is contained in:
@@ -9,7 +9,28 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
protected override string TomultipleSqlString(List<IGrouping<int, DbColumnInfo>> groupList)
|
protected override string TomultipleSqlString(List<IGrouping<int, DbColumnInfo>> groupList)
|
||||||
{
|
{
|
||||||
throw new Exception("Batch updates are not supported for the time being. Please wait for updates");
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.AppendLine(string.Join("\r\n", groupList.Select(t =>
|
||||||
|
{
|
||||||
|
var updateTable = string.Format("UPDATE {0} SET", base.GetTableNameStringNoWith);
|
||||||
|
var setValues = string.Join(",", t.Where(s => !s.IsPrimarykey).Select(m => GetOracleUpdateColums(m)).ToArray());
|
||||||
|
var pkList = t.Where(s => s.IsPrimarykey).ToList();
|
||||||
|
List<string> whereList = new List<string>();
|
||||||
|
foreach (var item in pkList)
|
||||||
|
{
|
||||||
|
var isFirst = pkList.First() == item;
|
||||||
|
var whereString = isFirst ? " " : " AND ";
|
||||||
|
whereString += GetOracleUpdateColums(item);
|
||||||
|
whereList.Add(whereString);
|
||||||
|
}
|
||||||
|
return string.Format("{0} {1} WHERE {2};", updateTable, setValues, string.Join("AND", whereList));
|
||||||
|
}).ToArray()));
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetOracleUpdateColums(DbColumnInfo m)
|
||||||
|
{
|
||||||
|
return string.Format("\"{0}\"={1}", m.DbColumnName.ToUpper(), FormatValue(m.Value));
|
||||||
}
|
}
|
||||||
public override object FormatValue(object value)
|
public override object FormatValue(object value)
|
||||||
{
|
{
|
||||||
|
Binary file not shown.
@@ -58,6 +58,8 @@ namespace OrmTest.Demo
|
|||||||
|
|
||||||
//Column is null no update
|
//Column is null no update
|
||||||
db.Updateable(updateObj).Where(true).ExecuteCommand();
|
db.Updateable(updateObj).Where(true).ExecuteCommand();
|
||||||
|
|
||||||
|
db.Updateable(new Student[] { new Student() { Id = 2, Name = "a2" }, new Student() { Id = 1, Name = "a1" } }).ExecuteCommand();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user