Skip to content
果糖网 edited this page Jul 21, 2024 · 3 revisions

1.1 Dictionary deletion (multi-library support)

// 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();

1.2 Spell SQL delete (not support multi-library)

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

1.3 Dynamic class mode (the most perfect support for multi-library)

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();