//可以是 Dictionary 或者 List<Dictionary >
var
dc=
new
Dictionary<
string
,
object
>();
dc.Add(
"name"
,
"1"
);
dc.Add(
"CreateTime"
, DateTime.Now);
db.Insertable(dc).AS(
"student"
).ExecuteCommand();
db.InsertableByDynamic(new { name="",price=1 }) .AS("OrderInfo") .ExecuteCommand();
db.Fastest<System.Data.DataTable>().AS("order").BulkCopy(dataTable); //具体用法 要看文档 https://www.donet5.com/Home/Doc?typeId=2404
该功能对多库支持更好,并且可以支持AOP等实体才有的功能
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()//缓存起来根据表名和字段名组合的KEY .BuilderType(); db.CodeFirst.InitTables(type); var value= db.DynamicBuilder().CreateObjectByType(type,new Dictionary<string, object>() { { "Id", 1 }, { "Name", "jack" } }); db.InsertableByObject(value).ExecuteCommand(); db.UpdateableByObject(value).ExecuteCommand(); db.DeleteableByObject(value).ExecuteCommand(); db.StorageableByObject(value).ExecuteCommand();//插入或者更新 db.Queryable<object>().AsType(type).Filter(type).ToList();
2016 © donet5.comApache Licence 2.0