/// <summary> /// 更新实体 /// </summary> /// <param name="entity"></param> /// <returns></returns> public virtual bool Update(T entity, IDbTransaction transaction = null) { using (DbBase DbContext = new DbBase(connectionName)) { bool returnBool = DbContext.Update(entity, transaction); DbContext.CloseConnection(); return(returnBool); } }
/// <summary> /// 删除实体 /// </summary> /// <param name="expr"></param> /// <param name="operation"></param> /// <param name="value"></param> public virtual bool Delete(DapperExQuery <T> query, IDbTransaction transaction = null) { bool flag = false; using (DbBase DbContext = new DbBase(connectionName)) { flag = DbContext.Delete <T>(query.GetSqlQuery(DbContext), transaction); DbContext.CloseConnection(); } return(flag); }
/// <summary> /// 批量删除实体 /// </summary> /// <param name="entityList"></param> public virtual void BatchDelete(List <T> entityList) { using (DbBase DbContext = new DbBase(connectionName)) { //自动新增事务处理 using (var tran = DbContext.GetDbTransaction()) { DbContext.DeleteBatch <T>(entityList, tran); tran.Commit(); } DbContext.CloseConnection(); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private void Close() throws java.io.IOException, java.sql.SQLException private void Close() { if ((this.outWriter_ != null) && (this.fileOutput_ == true)) { this.outWriter_.Close(); } if (this.inReader_ != null) { this.inReader_.Close(); } if (this.conn_ != null) { DbBase.CloseConnection(this.conn_); } }
public virtual void BatchUpdate(List <T> entityList) { using (DbBase DbContext = new DbBase(connectionName)) { bool success = true; //自动新增事务处理 using (var tran = DbContext.GetDbTransaction()) { try { foreach (var t in entityList) { DbContext.Update(t, tran); } } catch (Exception ex) { success = false; throw ex; } finally { if (success) { tran.Commit(); } else { tran.Rollback(); } } } DbContext.CloseConnection(); } }