/// <summary> /// 删除一行或多行记录 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="filter"></param> public void DeleteModel(ModelFilter filter) { string sql = SqlSplice.GetDelete(filter); try { SqlRequest.Update(sql, filter.Params.ToArray()); } catch (Exception ex) { throw new Exception("删除记录出错了", ex); } }
/// <summary> /// 更新一行记录 /// </summary> /// <param name="model"></param> public void UpdateModel(CModel model) { if (model == null) { return; } string sql = SqlSplice.GetUpdate(model); try { SqlRequest.Update(sql, SqlSplice.GetSqlParams()); } catch (Exception ex) { throw new Exception("更新一行记录出错了", ex); } }
/// <summary> /// 新增一行记录 /// </summary> /// <param name="model"></param> public void InsertModel(CModel model) { if (model == null) { return; } string sql = SqlSplice.GetInsert(model); try { SqlRequest.Update(sql, SqlSplice.GetSqlParams()); } catch (Exception ex) { throw ex; } }
/// <summary> /// 删除多行记录 /// </summary> /// <param name="models"></param> public void DeleteModels(List <CModel> models) { if (models.Count <= 0) { return; } foreach (var model in models) { string sql = SqlSplice.GetDelete(model); try { SqlRequest.Update(sql, SqlSplice.GetSqlParams()); } catch (Exception ex) { throw new Exception("删除多行记录出错了", ex); } } }