我在Sitefinity中有一个函数,它返回一个类别列表。
我想知道的是如何对这个列表进行排序。
据我所知,Sitefinity中的分类只是一个字符串,没有与分类相关联的其他字段。因此,我没有其他可用于对分类进行排序的信息,除了给每个分类添加一个数字,例如:
当这些类别显示在网站上时,至少我可以剪裁我需要的部分。
但是,有人能帮忙分类吗?
谢谢 Al
//return list of categories
private IList<ICategory> GetCategoryDataSource() {
var cntManager = new ContentManager(CaseStudyManager.DefaultContentProvider);
IList allCategories = cntManager.GetCategories();
List<ICategory> filteredList = new List<ICategory>();
foreach (ICategory category in allCategories) {
filteredList.Add(category);
}
return filteredList;
}
我想知道的是如何对这个列表进行排序。
据我所知,Sitefinity中的分类只是一个字符串,没有与分类相关联的其他字段。因此,我没有其他可用于对分类进行排序的信息,除了给每个分类添加一个数字,例如:
1 - Legal
2 - Financial
3 - Property
当这些类别显示在网站上时,至少我可以剪裁我需要的部分。
但是,有人能帮忙分类吗?
谢谢 Al
return filteredList.OrderBy(x => x.CategoryId).ToList()
。 - Martin