private void FillSubCategories(MongoCollection<category> database, int depth, category cat) { // Sanity check of recursiveness check if (depth >= MAX_DEPTH) return; if(cat.categories == null) { cat.categories = new System.Collections.Generic.List<ServiceModel.Types.category>(); if(!cat.categoryIDs.IsNullOrEmpty()) { foreach(ObjectId subCatId in cat.categoryIDs) { category subCat = database.FindOneById(subCatId); if(subCat != null) FillSubCategories(database, depth + 1, subCat); cat.categories.Add(subCat); } } } }
private void FillSubCategories(MongoCollection<category> database, category cat) { FillSubCategories(database, 0, cat); }