/// <summary> /// 带事务的Update /// </summary> /// <param name="entity"></param> /// <param name="trans">The trans.</param> /// <returns></returns> /// <remarks>2016/8/17 14:33:47</remarks> public bool Update(EuropeRecordEntity entity, DbTransaction trans = null) { var database = new SqlDatabase(this.ConnectionString); DbCommand commandWrapper = database.GetStoredProcCommand("dbo.P_EuropeRecord_Update"); database.AddInParameter(commandWrapper, "@Idx", DbType.Int32, entity.Idx); database.AddInParameter(commandWrapper, "@ManagerId", DbType.Guid, entity.ManagerId); database.AddInParameter(commandWrapper, "@Season", DbType.Int32, entity.Season); database.AddInParameter(commandWrapper, "@CorrectNumber", DbType.Int32, entity.CorrectNumber); database.AddInParameter(commandWrapper, "@PrizeRecord", DbType.AnsiString, entity.PrizeRecord); database.AddInParameter(commandWrapper, "@RowTime", DbType.DateTime, entity.RowTime); 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的当前记录读取到EuropeRecordEntity 对象 /// </summary> /// <param name="reader"></param> /// <returns></returns> public EuropeRecordEntity LoadSingleRow(IDataReader reader) { var obj = new EuropeRecordEntity(); obj.Idx = (System.Int32)reader["Idx"]; obj.ManagerId = (System.Guid)reader["ManagerId"]; obj.Season = (System.Int32)reader["Season"]; obj.CorrectNumber = (System.Int32)reader["CorrectNumber"]; obj.PrizeRecord = (System.String)reader["PrizeRecord"]; obj.RowTime = (System.DateTime)reader["RowTime"]; return(obj); }
/// <summary> /// GetById /// </summary> /// <param name="idx">idx</param> /// <returns>EuropeRecordEntity</returns> /// <remarks>2016/8/17 14:33:47</remarks> public EuropeRecordEntity GetById(System.Int32 idx) { var database = new SqlDatabase(this.ConnectionString); DbCommand commandWrapper = database.GetStoredProcCommand("P_EuropeRecord_GetById"); database.AddInParameter(commandWrapper, "@Idx", DbType.Int32, idx); EuropeRecordEntity obj = null; using (IDataReader reader = database.ExecuteReader(commandWrapper)) { if (reader.Read()) { obj = LoadSingleRow(reader); } } return(obj); }
public static bool Update(EuropeRecordEntity europeRecordEntity, DbTransaction trans = null, string zoneId = "") { var provider = new EuropeRecordProvider(zoneId); return(provider.Update(europeRecordEntity, trans)); }