コード例 #1
0
        public static List <Product> GetGroceryProducts(Grocerylist groceryList)
        {
            using (OracleConnection connection = Connection)
            {
                try
                {
                    OracleCommand command = CreateOracleCommand(connection, "SELECT * FROM PRODUCT WHERE ID = BOODSCHAPPENLIJST_PRODUCTEN.product_ID AND BOODSCHAPPENLIJST_PRODUCTEN.boodschappenlijst_ID = :groceryListID");
                    command.Parameters.Add(":groceryListID", groceryList.ID);
                    OracleDataReader reader   = ExecuteQuery(command);
                    List <Product>   products = new List <Product>();

                    while (reader.Read())
                    {
                        int      id           = Convert.ToInt32(reader["ID"].ToString());
                        string   name         = reader["naam"].ToString();
                        string   imageURL     = reader["imgurl"].ToString();
                        double   price        = Convert.ToDouble(reader["prijs"].ToString());
                        DateTime lastModified = Convert.ToDateTime(reader["laastgewijzigd"].ToString());

                        products.Add(new Product(id, name, price, imageURL, lastModified, null));
                    }
                    return(products);
                }
                finally
                {
                    connection.Close();
                }
            }
        }
コード例 #2
0
        public static List<Product> GetGroceryProducts(Grocerylist groceryList)
        {
            using (OracleConnection connection = Connection)
            {
                try
                {
                    OracleCommand command = CreateOracleCommand(connection, "SELECT * FROM PRODUCT WHERE ID = BOODSCHAPPENLIJST_PRODUCTEN.product_ID AND BOODSCHAPPENLIJST_PRODUCTEN.boodschappenlijst_ID = :groceryListID");
                    command.Parameters.Add(":groceryListID", groceryList.ID);
                    OracleDataReader reader = ExecuteQuery(command);
                    List<Product> products = new List<Product>();

                    while (reader.Read())
                    {
                        int id = Convert.ToInt32(reader["ID"].ToString());
                        string name = reader["naam"].ToString();
                        string imageURL = reader["imgurl"].ToString();
                        double price = Convert.ToDouble(reader["prijs"].ToString());
                        DateTime lastModified = Convert.ToDateTime(reader["laastgewijzigd"].ToString());

                        products.Add(new Product(id, name, price, imageURL, lastModified, null));
                    }
                    return products;
                }
                finally
                {
                    connection.Close();
                }
            }
        }