1.1 insert into not exists (只插入不更新)
主键不存在则插入(判断新增)
var x = Db.Storageable(list).SplitInsert(it => !it.Any()).ToStorage() x.AsInsertable.ExecuteCommand(); //插入可插入部分 //缩写 var x = Db.Storageable(list) .SplitInsert(it => !it.Any()) .ToStorage() .AsInsertable.ExecuteCommand(); |
1.2 非主键用例
var x = Db.Storageable(list) .SplitInsert(it => !it.Any()) .WhereColumns(it=>it.Id) //如果不是主键可以这样实现(多字段it=>new{it.x1,it.x2}) .ToStorage() x.AsInsertable.ExecuteCommand(); //插入可插入部分 |