コード例 #1
0
 /// <summary>
 /// クローン用コンストラクタ
 /// </summary>
 /// <param name="pesticideMaster"></param>
 public PesticideMaster(PesticideMaster pesticideMaster)
 {
     this.Id          = pesticideMaster.Id;
     this.Name        = pesticideMaster.Name;
     this.Unit        = pesticideMaster.Unit;
     this.URI         = pesticideMaster.URI;
     this.Description = pesticideMaster.Description;
 }
コード例 #2
0
        /// <summary>
        /// 農薬マスタリスト取得
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public List <PesticideMaster> GetPesticideMasters(int id = -1)
        {
            List <PesticideMaster> result = new List <PesticideMaster>();

            try
            {
                if (-1 != id)
                {
                    PrepareCommandParameter("SELECT * FROM M_Pesticide WHERE id = ?", new List <object> {
                        id
                    });
                }
                else
                {
                    command.CommandText = "SELECT * FROM M_Pesticide";
                }

                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        PesticideMaster tmp = new PesticideMaster()
                        {
                            Id          = int.Parse(reader["id"].ToString()),
                            Name        = reader["name"].ToString(),
                            Unit        = reader["unit"].ToString(),
                            URI         = reader["uri"].ToString(),
                            Description = reader["description"].ToString()
                        };

                        result.Add(tmp);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new SQLiteException(ex.ToString());
            }
            return(result);
        }