示例#1
0
 public static void PopulateParentCategoryList(IDataReader dr, ParentCategory _parentCategory)
 {
     _parentCategory.CategoryID         = (int)dr["categoryid"];
     _parentCategory.ParentCategoryID   = (int)dr["parentcategoryid"];
     _parentCategory.ParentCategoryName = dr["categoryname"] as string;
     _parentCategory.NumActiveProducts  = (int)dr["NumActiveProducts"];
 }
        public override List <ParentCategory> GetParentCategoryList(int categoryID)
        {
            List <ParentCategory> list = new List <ParentCategory>();

            using (SqlConnection connection = this.GetSqlConnection())
            {
                using (SqlCommand command = new SqlCommand("SuCommerce_ParentCategoriesByID_Get", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add("@categoryID", SqlDbType.Int, 4).Value = categoryID;
                    connection.Open();
                    using (SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection))
                    {
                        ParentCategory category = null;
                        while (reader.Read())
                        {
                            category = new ParentCategory();
                            CommerceDataProvider.PopulateParentCategoryList(reader, category);
                            list.Add(category);
                        }
                        reader.Close();
                        connection.Close();
                    }
                    return(list);
                }
            }
        }