/// <summary> /// 批量删除 /// </summary> /// <param name="idList"></param> /// <returns></returns> public bool DeleteList(List <int> idList, int actType) { Type type = typeof(T); List <CommandInfo> comList = new List <CommandInfo>(); foreach (int id in idList) { string strWhere = $"[{type.GetPrimary()}]=@Id"; string delSql = ""; if (actType == 1) { delSql = CreateSql.CreateDeleteSql <T>(strWhere); } else { delSql = $"update [{type.GetTName()}] set IsDeleted=1 where {strWhere}"; } SqlParameter[] paras = { new SqlParameter("@Id", id) }; CommandInfo com = new CommandInfo(delSql, false, paras); comList.Add(com); } return(SqlHelper.ExecuteTrans(comList)); }
/// <summary> /// 按条件删除数据 /// </summary> /// <param name="strWhere">条件</param> /// <param name="paras">参数列表</param> /// <returns></returns> public bool Delete(int actType, string strWhere, SqlParameter[] paras) { Type type = typeof(T); string delSql = ""; if (actType == 1) { delSql = CreateSql.CreateDeleteSql <T>(strWhere); } else { delSql = $"update [{type.GetTName()}] set IsDeleted=1 where {strWhere}"; } List <CommandInfo> list = new List <CommandInfo>(); list.Add(new CommandInfo() { CommandText = delSql, IsProc = false, Paras = paras }); return(SqlHelper.ExecuteTrans(list)); }