This is a two part question really (at the end).
Let's say I have a DB table of businesses. Each business has a category field, filled with a category "slug" (food-restaurant-brazilian for example). Instead of building a BusinessCategory DB table, I'm just going to build it in-code. Something like this:
public class BizCategory {
public string Slug {get; set;}
public string Name {get; set;}
public string Icon {get; set;}
public string Description {get; set;}
...
public IQueryable<BizCategory>() AllCategories {
List<BizCategory> bizCatList = new List<BizCategory>();
bizCatList.Add(new BizCategory { Slug = "food-restaurant-brazilian", Name = "Brazilian Restaurant", Icon = "icon.png", Description = "Places to eat Brazilian food"});
bizCatList.Add(new BizCategory { Slug = "food-restaurant-italian", Name = "Italian Restaurant", Icon = "icon.png", Description = "Places to eat Italian food"});
bizCatList.Add(new BizCategory { Slug = "food-restaurant-japanese", Name = "Japanese Restaurant", Icon = "icon.png", Description = "Places to eat Japanese food"});
...
return bizCatList.AsQueryable<BizCategory>();
}
}
Then whenever I need the name of a category, by it's slug I could call BizCategory.AllCategories().Where(c => c.Slug == "food-restaurant-brazilian").First().Name;
Instead of hitting the DB, it would be from an in-memory collection. The idea is to reduce table joins and network latency to increase performance of my site. One issue I see would be that category changes would need to be done in code, harder to change on the fly.
1) Have you done this before? Any particular issues that I should look out for?
2) Do you know of a source for a good list of business categories? Perhaps similar to the list of ad categories on eBay classifieds, but tailored for business types.