예제 #1
0
        public Plant GetPlant(int id)
        {
            using (QMySql s = new QMySql())
            {
                s.Open(@"
select * from plants where id=@1", id);
                if (s.GetRow())
                {
                    Plant p = new Plant();
                    QObject.PopulateFromRow(s, p);

                    p.habitats = QMySql.SqlList(@"
select h.name 
from habitats h
inner join plantHabitat p on p.habitat_id=h.id
where p.plant_id=" + id).ToList();

                    p.uses = QMySql.SqlList(@"
select h.name 
from uses h
inner join plantUse p on p.use_id=h.id
where p.plant_id=" + id).ToList();

                    p.soilPreferences = QMySql.SqlList(@"
select h.name 
from soilPreferences h
inner join plantSoilPreference p on p.soilPreference_id=h.id
where p.plant_id=" + id).ToList();

                    p.shadePreferences = QMySql.SqlList(@"
select h.name 
from shadePreferences h
inner join plantShadePreference p on p.shadePreference_id=h.id
where p.plant_id=" + id).ToList();
                    p.images           = QMySql.SqlList(@"
select p.image 
from plantImages p
where p.plant_id=" + id + " order by p.seq").ToList();

                    p.heatMapData = GetHeatMapData(p.habitats);

                    return(p);
                }
            }

            throw new ArgumentException();
        }
예제 #2
0
        public IEnumerable <string> GetShadePreferences()
        {
            return(QMySql.SqlList(@"
select name from shadePreferences order by 1"));
        }
예제 #3
0
        public IEnumerable <string> GetUses()
        {
            return(QMySql.SqlList(@"
select name from uses order by 1"));
        }
예제 #4
0
        public PlantAttributeList GetHabitats()
        {
            return(new PlantAttributeList(QMySql.SqlList(@"
select name from habitats order by 1")));
        }
예제 #5
0
        public PlantAttributeList GetPlantTypes()
        {
            return(new PlantAttributeList(QMySql.SqlList(@"
select distinct plantType from plants order by 1")));
        }