public SYS_Population SelectSYS_Population(int ID) { SYS_Population sys_population = new SYS_Population(); DbDataReader reader = null; DbConnection conn = _DbHelper.CreateConnection(Common.ConnectionString); conn.Open(); try { List <DbParameter> para = new List <DbParameter>(); para.Add(_DbHelper.CreateParameter(FIELD_ID, ID, false)); reader = _DbHelper.ExecuteReader(conn, Common.DatabaseSchema + "[SYS_Population_SelectById]", para.ToArray()); if (reader.HasRows && reader.Read()) { SYS_PopulationDataAccess.SetSYS_PopulationInfo(reader, ref sys_population); } return(sys_population); } catch (Exception ex) { throw new Exception(String.Format("SYS_PopulationDataAccess.SelectById: {0}", ex.Message)); } finally { if (reader != null) { reader.Close(); } conn.Close(); } }
private static void SetListSYS_PopulationInfo(ref DbDataReader reader, ref List <SYS_Population> sys_populations) { SYS_Population sys_population = null; int count = 0; while (reader.Read()) { sys_population = new SYS_Population(); SYS_PopulationDataAccess.SetSYS_PopulationInfo(reader, ref sys_population); sys_population.STT = count + 1; sys_populations.Add(sys_population); } }