| | |
| | | using Rhea.Common; |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Data.SqlTypes; |
| | | using System.Linq; |
| | |
| | | { |
| | | var dbres = isAsync ? await Db.Deleteable<T>().In(primaryKeys).ExecuteCommandAsync() : Db.Deleteable<T>().In(primaryKeys).ExecuteCommand(); |
| | | action.Message = $"Delete {typeof(T).Name} entity by primary keys from database success"; |
| | | action.IsSuccessed = true; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | { |
| | | var dbres = isAsync ? await Db.Deleteable<T>().Where(entity).ExecuteCommandAsync() : Db.Deleteable<T>().Where(entity).ExecuteCommand(); |
| | | action.Message = $"Delete {typeof(T).Name} entity from database success"; |
| | | action.IsSuccessed = true; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | } |
| | | |
| | | #endregion 执行SQL |
| | | |
| | | #region 先删除后新增 |
| | | /// <summary> |
| | | /// 删除完更新 |
| | | /// </summary> |
| | | /// <typeparam name="T"></typeparam> |
| | | /// <param name="query"></param> |
| | | /// <param name="list"></param> |
| | | /// <returns></returns> |
| | | public new async Task<ApiAction> AddAfterDeleteAsync<T>(QueryAble<T> query) where T : class, new() |
| | | { |
| | | var action = new ApiAction(); |
| | | try |
| | | { |
| | | //保存到数据库 |
| | | var db = Business.Biz.Db; |
| | | var dbTran = db.UseTran(() => |
| | | { |
| | | var dbres = !query.where.IsNullOrEmpty() ? db.Deleteable<T>().Where(query.where).ExecuteCommand() : db.Deleteable<T>().ExecuteCommand(); |
| | | if (query.Items.Count > 0) |
| | | { |
| | | db.Insertable<T>(query.Items).ExecuteCommand(); |
| | | } |
| | | }); |
| | | if (!dbTran.IsSuccess) |
| | | { |
| | | action.GetResponse().CatchExceptionWithLog(dbTran.ErrorException, $"作业保存到数据库异常"); |
| | | } |
| | | action.Message = $"Delete {typeof(T).Name} entity by where and add list in database success"; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | action.CatchExceptionWithLog(ex, $"Delete {typeof(T).Name} entity by where and add list in database exception"); |
| | | } |
| | | return action; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | }//endClass |
| | | } |