Inheritance: IDisposable
示例#1
0
 private static List<CachedCategory> FetchCategoriesByParentId(int parentCategoryId)
 {
     List<CachedCategory> subCategories = new List<CachedCategory>();
     using (CategoriesDB db = new CategoriesDB())
     {
         FetchCategoriesRecursively(false, subCategories, db, parentCategoryId, String.Empty);
     }
     return subCategories;
 }
示例#2
0
        private static void FetchCategoriesRecursively(bool recursing, List<CachedCategory> list, CategoriesDB db, int categoryId, string levelPrefix)
        {
            CategoriesDataComponent.CategoriesDataTable subCategories = db.GetCategoriesByParentId(categoryId);

            if (subCategories != null)
            {
                string categoryIdString = categoryId.ToString();
                foreach (CategoriesDataComponent.CategoriesRow category in subCategories)
                {
                    list.Add(new CachedCategory(category.Name, category.Id, categoryId, category.NumActiveAds, levelPrefix));

                    if (recursing)
                        FetchCategoriesRecursively(recursing, list, db, category.Id, levelPrefix + "--");
                }
            }
        }
示例#3
0
 private static List<CachedCategory> FetchAllCategories()
 {
     List<CachedCategory> list = new List<CachedCategory>();
     using (CategoriesDB db = new CategoriesDB())
     {
         FetchCategoriesRecursively(true, list, db, DefaultValues.CategoryIdMinValue, String.Empty);
     }
     return list;
 }