I believe that I'm going to need to use an html helper method that uses lambda expressions to accomplish this.
I was thinking of doing something along these lines:
public static MvcHtmlString GetCategoryBreadCrumbs<T>(
this HtmlHelper html,
IEnumerable<T> currentCat,
Func<T, T> parentProperty,
Func<T, string> itemContent)
{
var sb = new StringBuilder();
sb.AppendLine(itemContent(currentCat));
if (currentCat.parentProperty.Count() > 0)
sb.AppendLine(GetCategoryBreadCrumbs(html, currentCat.parentProperty, itemContent);
return MvcHtmlString.Create(sb.ToString());
}
And then I would want to call it similar to this:
<%: Html.GetCategoryBreadCrumbs(
Model, l => l.parentCategories,
l => l.catID,
l => l.catName)%>
Obviously, what I have above is horrible even at a pseudo-code level.
How do Lamba/Generic methods work?