コード例 #1
0
        public override bool Equals(System.Object otherPony)
        {
            if (!(otherPony is Pony))
            {
                return(false);
            }
            else
            {
                Pony newPony             = otherPony as Pony;
                bool nameEquality        = (this.GetName() == newPony.GetName());
                bool typeEquality        = (this.GetPonyType() == newPony.GetPonyType());
                bool cutieMarkEquality   = (this.GetCutieMark() == newPony.GetCutieMark());
                bool productTypeEquality = (this.GetProductType() == newPony.GetProductType());
                bool allEquality;

                if (nameEquality && typeEquality && cutieMarkEquality && productTypeEquality)
                {
                    allEquality = true;
                }
                else
                {
                    allEquality = false;
                }

                return(allEquality);
            }
        }
コード例 #2
0
        public static List <Pony> GetAll()
        {
            List <Pony> allPonys = new List <Pony> {
            };
            MySqlConnection conn = DB.Connection();

            conn.Open();
            MySqlCommand cmd = conn.CreateCommand() as MySqlCommand;

            cmd.CommandText = @"SELECT * FROM pony;";
            MySqlDataReader rdr = cmd.ExecuteReader() as MySqlDataReader;

            while (rdr.Read())
            {
                int    ponyId          = rdr.GetInt32(0);
                string ponyName        = rdr.GetString(1);
                string ponyType        = rdr.GetString(2);
                string ponyCutieMark   = rdr.GetString(3);
                string ponyProductType = rdr.GetString(4);
                Pony   newPony         = new Pony(ponyName, ponyType, ponyCutieMark, ponyProductType, ponyId);
                allPonys.Add(newPony);
            }
            conn.Close();
            if (conn != null)
            {
                conn.Dispose();
            }
            return(allPonys);
        }