mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Update Sqlite
This commit is contained in:
parent
6b9cdde372
commit
e3d1955a53
@ -9,7 +9,28 @@ namespace SqlSugar
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
Binary file not shown.
@ -58,6 +58,8 @@ namespace OrmTest.Demo
|
||||
|
||||
//Column is null no update
|
||||
db.Updateable(updateObj).Where(true).ExecuteCommand();
|
||||
|
||||
db.Updateable(new Student[] { new Student() { Id = 2, Name = "a2" }, new Student() { Id = 1, Name = "a1" } }).ExecuteCommand();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user