-
Notifications
You must be signed in to change notification settings - Fork 1.3k
4.2 Dynamic Delete
果糖网 edited this page Jul 21, 2024
·
3 revisions
// Delete according to the dictionary set
List<Dictionary<string,object>> list= new List<Dictionary<string,object>>;
list.Add(dictionary);
db.Deleteable<object>().AS("OrderInfo").WhereColumns(list).ExecuteCommand();
If there are some special syntax can not do multi-library compatibility
db.Deleteable<object>().AS("OrderInfo").Where("id=@id",new { id=1}).ExecuteCommand();
Db. Deleteable < object > () AS (" OrderInfo "). The Where (" id in (@ id) ", the new {id = new int [] {1, 2, 3}}). The ExecuteCommand (); // Batch
var type = db.DynamicBuilder().CreateClass("table1", new SugarTable()
{
})
.CreateProperty("Id",typeof(int),new SugarColumn(){IsPrimaryKey=true,IsIdentity = true })
.CreateProperty("Name",typeof(string), new SugarColumn() { })
.withcache ()// Cache the KEY, which is based on the table name and field name.
.BuilderType();
db.CodeFirst.InitTables(type);
var dic=new Dictionary<string, object>(){{ "Id", 1 }, { "Name", "jack" }};
var value= db.DynamicBuilder().CreateObjectByType(type,dic);
db.InsertableByObject(value).ExecuteCommand();
db.UpdateableByObject(value).ExecuteCommand();
db.DeleteableByObject(value).ExecuteCommand();
db.StorageableByObject(value).ExecuteCommand(); // Insert or update
// Query 5.1.4.84-preview09+
db.QueryableByObject(typeof(OrderSpliteTest)).ToList();