知识要点
事务,常用于多条数据 的增删查改
例子:
try {
1: DbClient.Ado.BeginTran(); DbClient.Saveable(model).UpdateIgnoreColumns(a => new { a.createdOn, a.createdBy }).InsertIgnoreColumns(a => new { a.modifiedOn, a.modifiedBy }).ExecuteCommand(); DbClient.Deleteable<crms_membership_group_detail>().Where(a => a.crms_membergroup_hdrId == model.crms_membership_group_headerId).ExecuteCommand(); if (list.Count > 0) DbClient.Saveable(list).ExecuteCommand(); 2: DbClient.Ado.CommitTran(); return OkResult(true); } catch (Exception ex) {
3:这里必须回滚 不然会造成死锁 DbClient.Ado.RollbackTran(); return OkResult(ex); }