/// <summary> /// 带事务的Update /// </summary> /// <param name="entity"></param> /// <param name="trans">The trans.</param> /// <returns></returns> /// <remarks>2016/3/3 17:36:44</remarks> public bool Update(ActivityHistoryEntity entity, DbTransaction trans = null) { var database = new SqlDatabase(this.ConnectionString); DbCommand commandWrapper = database.GetStoredProcCommand("dbo.P_ActivityHistory_Update"); database.AddInParameter(commandWrapper, "@Idx", DbType.Int32, entity.Idx); database.AddInParameter(commandWrapper, "@ManagerId", DbType.Guid, entity.ManagerId); database.AddInParameter(commandWrapper, "@ActivityId", DbType.Int32, entity.ActivityId); database.AddInParameter(commandWrapper, "@ActivityStep", DbType.Int32, entity.ActivityStep); database.AddInParameter(commandWrapper, "@StepRecord", DbType.AnsiString, entity.StepRecord); database.AddInParameter(commandWrapper, "@RecordDate", DbType.DateTime, entity.RecordDate); database.AddInParameter(commandWrapper, "@Status", DbType.Int32, entity.Status); database.AddInParameter(commandWrapper, "@RowTime", DbType.DateTime, entity.RowTime); database.AddInParameter(commandWrapper, "@UpdateTime", DbType.DateTime, entity.UpdateTime); int results = 0; if (trans != null) { results = database.ExecuteNonQuery(commandWrapper, trans); } else { results = database.ExecuteNonQuery(commandWrapper); } entity.Idx = (System.Int32)database.GetParameterValue(commandWrapper, "@Idx"); return(Convert.ToBoolean(results)); }
/// <summary> /// 将IDataReader的当前记录读取到ActivityHistoryEntity 对象 /// </summary> /// <param name="reader"></param> /// <returns></returns> public ActivityHistoryEntity LoadSingleRow(IDataReader reader) { var obj = new ActivityHistoryEntity(); obj.Idx = (System.Int32)reader["Idx"]; obj.ManagerId = (System.Guid)reader["ManagerId"]; obj.ActivityId = (System.Int32)reader["ActivityId"]; obj.ActivityStep = (System.Int32)reader["ActivityStep"]; obj.StepRecord = (System.String)reader["StepRecord"]; obj.RecordDate = (System.DateTime)reader["RecordDate"]; obj.Status = (System.Int32)reader["Status"]; obj.RowTime = (System.DateTime)reader["RowTime"]; obj.UpdateTime = (System.DateTime)reader["UpdateTime"]; return(obj); }
/// <summary> /// GetById /// </summary> /// <param name="idx">idx</param> /// <returns>ActivityHistoryEntity</returns> /// <remarks>2016/3/3 17:36:44</remarks> public ActivityHistoryEntity GetById(System.Int32 idx) { var database = new SqlDatabase(this.ConnectionString); DbCommand commandWrapper = database.GetStoredProcCommand("P_ActivityHistory_GetById"); database.AddInParameter(commandWrapper, "@Idx", DbType.Int32, idx); ActivityHistoryEntity obj = null; using (IDataReader reader = database.ExecuteReader(commandWrapper)) { if (reader.Read()) { obj = LoadSingleRow(reader); } } return(obj); }
public static bool Update(ActivityHistoryEntity activityHistoryEntity, DbTransaction trans = null, string zoneId = "") { var provider = new ActivityHistoryProvider(zoneId); return(provider.Update(activityHistoryEntity, trans)); }