예제 #1
0
        protected override IList <Animal> Read(DbDataReader reader)
        {
            IList <Animal>   animals      = new List <Animal>();
            OracleDataReader oracleReader = (OracleDataReader)reader;

            while (oracleReader.Read())
            {
                int    i      = -1;
                Animal animal = new Animal();
                animal.Id        = oracleReader.GetInt32(++i);
                animal.Name      = oracleReader.GetString(++i);
                animal.Race      = oracleReader.GetString(++i);
                animal.BirthDate = oracleReader.GetDateTime(++i);
                animal.Sex       = SexEnumUtils.getSexEnum(oracleReader.GetString(++i));
                animal.Active    = oracleReader.GetString(++i) == "1" ? true : false;

                animal.AnimalGroup             = new AnimalGroup();
                animal.AnimalGroup.Id          = oracleReader.GetInt32(++i);
                animal.AnimalGroup.Description = oracleReader.GetString(++i);

                animal.Cage         = new Cage();
                animal.Cage.Id      = oracleReader.GetInt32(++i);
                animal.Cage.LengthM = oracleReader.GetInt32(++i);
                animal.Cage.WidthM  = oracleReader.GetInt32(++i);

                animal.Food                = new Food();
                animal.Food.Id             = oracleReader.GetInt32(++i);
                animal.Food.Name           = oracleReader.GetString(++i);
                animal.Food.Price          = oracleReader.GetDouble(++i);
                animal.Food.Proteins       = oracleReader.GetInt32(++i);
                animal.Food.Carbohydrates  = oracleReader.GetInt32(++i);
                animal.Food.Fat            = oracleReader.GetInt32(++i);
                animal.Food.FoodRunningOut = oracleReader.GetString(++i) == "1" ? true : false;

                animal.Food.Company    = new Company();
                animal.Food.Company.Id = oracleReader.GetInt32(++i);

                animals.Add(animal);
            }
            return(animals);
        }
        protected override IList <Animal> Read(DbDataReader reader)
        {
            IList <Animal> animals   = new List <Animal>();
            SqlDataReader  sqlReader = (SqlDataReader)reader;

            while (sqlReader.Read())
            {
                int    i      = -1;
                Animal animal = new Animal();
                animal.Id        = sqlReader.GetInt32(++i);
                animal.Name      = sqlReader.GetString(++i);
                animal.Race      = sqlReader.GetString(++i);
                animal.BirthDate = sqlReader.GetDateTime(++i);
                animal.Sex       = SexEnumUtils.getSexEnum(sqlReader.GetString(++i));
                animal.Active    = sqlReader.GetBoolean(++i);

                animal.AnimalGroup             = new AnimalGroup();
                animal.AnimalGroup.Id          = sqlReader.GetInt32(++i);
                animal.AnimalGroup.Description = sqlReader.GetString(++i);

                animal.Cage         = new Cage();
                animal.Cage.Id      = sqlReader.GetInt32(++i);
                animal.Cage.LengthM = sqlReader.GetInt32(++i);
                animal.Cage.WidthM  = sqlReader.GetInt32(++i);

                animal.Food                = new Food();
                animal.Food.Id             = sqlReader.GetInt32(++i);
                animal.Food.Name           = sqlReader.GetString(++i);
                animal.Food.Price          = (double)sqlReader.GetDecimal(++i);
                animal.Food.Proteins       = sqlReader.GetInt32(++i);
                animal.Food.Carbohydrates  = sqlReader.GetInt32(++i);
                animal.Food.Fat            = sqlReader.GetInt32(++i);
                animal.Food.FoodRunningOut = sqlReader.GetBoolean(++i);

                animal.Food.Company    = new Company();
                animal.Food.Company.Id = sqlReader.GetInt32(++i);

                animals.Add(animal);
            }
            return(animals);
        }