mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 13:06:50 +08:00
Update access
This commit is contained in:
parent
c7175d7ecf
commit
2cc045edee
@ -32,36 +32,16 @@ namespace OrmTest
|
||||
|
||||
|
||||
//insert or update
|
||||
var x= db.Storageable<Order>(new Order() { Id=1, Name="jack" }).ToStorage();
|
||||
x.AsUpdateable.ExecuteCommand();
|
||||
var x= db.Storageable<Order>(new Order() { Id=159, Name="jack" }).ToStorage();
|
||||
var updateRow=x.AsUpdateable.ExecuteCommand();
|
||||
x.AsInsertable.ExecuteCommand();
|
||||
|
||||
|
||||
var x2 = db.Storageable<Order>(new Order() { Id = 0, Name = "jack" }).ToStorage();
|
||||
x2.BulkCopy();
|
||||
x2.BulkUpdate();
|
||||
|
||||
var dt = db.Queryable<Order>().Take(1).ToDataTable();
|
||||
dt.TableName = "order";
|
||||
var addRow = dt.NewRow();
|
||||
addRow["id"] = 0;
|
||||
addRow["price"] = 1;
|
||||
addRow["Name"] = "a";
|
||||
dt.Rows.Add(addRow);
|
||||
var x3 =
|
||||
db.Storageable(dt)
|
||||
.WhereColumns("id").ToStorage();
|
||||
|
||||
x3.AsInsertable.IgnoreColumns("id").ExecuteCommand();
|
||||
x3.AsUpdateable.ExecuteCommand();
|
||||
var updateRow2 = x2.AsUpdateable.ExecuteCommand();
|
||||
x2.AsInsertable.ExecuteCommand();
|
||||
|
||||
|
||||
var x4 =
|
||||
db.Storageable(dt)
|
||||
.SplitDelete(it=>Convert.ToInt32( it["id"])>0)
|
||||
.WhereColumns("id").ToStorage();
|
||||
x4.AsDeleteable.ExecuteCommand();
|
||||
|
||||
db.Saveable(new Order() { Id = 159, Name = "jack" }).ExecuteCommand();
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("#### Saveable End ####");
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ namespace OrmTest
|
||||
Demo3_Insertable.Init();
|
||||
Demo4_Deleteable.Init();
|
||||
Demo5_SqlQueryable.Init();
|
||||
Demo8_Saveable.Init();
|
||||
Demo7_Ado.Init();
|
||||
DemoD_DbFirst.Init();
|
||||
Console.WriteLine("all successfully.");
|
||||
|
@ -9,9 +9,20 @@ namespace SqlSugar.Access
|
||||
public class AccessUpdateBuilder : UpdateBuilder
|
||||
{
|
||||
protected override string TomultipleSqlString(List<IGrouping<int, DbColumnInfo>> groupList)
|
||||
{
|
||||
if (groupList.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else if (groupList.GroupBy(it => it.Key).Count() > 1)
|
||||
{
|
||||
throw new Exception("access no support batch update");
|
||||
}
|
||||
else
|
||||
{
|
||||
return ToSingleSqlString(groupList);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.1.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.1.0.0")]
|
||||
[assembly: AssemblyVersion("1.2.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.2.0.0")]
|
||||
|
Loading…
Reference in New Issue
Block a user