| | |
| | | |
| | | List<TDetail> list = detailDics.DicToIEnumerable<TDetail>(); |
| | | |
| | | ((SqlSugarClient)BaseDal.Db).BeginTran(); |
| | | ((SqlSugarScope)BaseDal.Db).BeginTran(); |
| | | |
| | | int id = BaseDal.Db.Insertable(entity).ExecuteReturnIdentity(); |
| | | |
| | |
| | | |
| | | BaseDal.Db.Insertable(list).ExecuteCommand(); |
| | | |
| | | ((SqlSugarClient)BaseDal.Db).CommitTran(); |
| | | ((SqlSugarScope)BaseDal.Db).CommitTran(); |
| | | |
| | | content = WebResponseContent.Instance.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | ((SqlSugarClient)BaseDal.Db).RollbackTran(); |
| | | ((SqlSugarScope)BaseDal.Db).RollbackTran(); |
| | | content = WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | return content; |
| | |
| | | object mainId = typeof(TEntity).GetPropertyValue(entity, typeof(TEntity).GetKeyName()); |
| | | if (mainId != null) |
| | | { |
| | | ((SqlSugarClient)BaseDal.Db).BeginTran(); |
| | | ((SqlSugarScope)BaseDal.Db).BeginTran(); |
| | | |
| | | if (dynamicDelKeys.Count > 0) |
| | | BaseDal.Db.Deleteable<object>().AS(detailType.Name).Where($"{detailType.GetKeyName()} in (@id)", new { id = dynamicDelKeys.ToArray() }).ExecuteCommandHasChange(); |
| | |
| | | |
| | | BaseDal.Db.Insertable(addRows).ExecuteCommand(); |
| | | |
| | | ((SqlSugarClient)BaseDal.Db).CommitTran(); |
| | | ((SqlSugarScope)BaseDal.Db).CommitTran(); |
| | | |
| | | content = WebResponseContent.Instance.OK(); |
| | | } |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | ((SqlSugarClient)BaseDal.Db).RollbackTran(); |
| | | ((SqlSugarScope)BaseDal.Db).RollbackTran(); |
| | | content = WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | return content; |
| | |
| | | { |
| | | dynamicDelKeys.Add(keys[i]); |
| | | } |
| | | ((SqlSugarClient)BaseDal.Db).BeginTran(); |
| | | ((SqlSugarScope)BaseDal.Db).BeginTran(); |
| | | |
| | | if (dynamicDelKeys.Count > 0) |
| | | BaseDal.Db.Deleteable<object>().AS(detailType.Name).Where($"{name} in (@id)", new { id = dynamicDelKeys.ToArray() }).ExecuteCommandHasChange(); |
| | | |
| | | BaseDal.DeleteDataByIds(keys); |
| | | |
| | | ((SqlSugarClient)BaseDal.Db).CommitTran(); |
| | | ((SqlSugarScope)BaseDal.Db).CommitTran(); |
| | | |
| | | return WebResponseContent.Instance.OK(); |
| | | } |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | ((SqlSugarClient)BaseDal.Db).RollbackTran(); |
| | | ((SqlSugarScope)BaseDal.Db).RollbackTran(); |
| | | return WebResponseContent.Instance.Error(ex.Message); |
| | | } |
| | | } |