In the example for Project List, you may apply a filter. If you send a filter as criteria, the project list is fetched and then only filtered items are added to the list.
I also noticed that this list may reside in memory for a while, in cache. It appears, then, that a filtered list could be the list in cache.
Is it viable, and by that I mean "not bad practice" to retrieve full lists (if they are relatively small), keep the full list in memory (thus momentarily no more requests to the database are necessary) and do this:
private
static CompetencyList _list; /// <summary> /// Returns a list of competencies. /// </summary> public static CompetencyList GetCompetencyList(int categoryId){
if (_list == null)_list =
DataPortal.Fetch<CompetencyList>(
new Criteria()); //return _list; if (categoryId > 0){
CompetencyList newList = new CompetencyList();newList.IsReadOnly =
false; for (int i = 0; i <= _list.Items.Count - 1; i++){
if (_list.Items.CategoryId == categoryId)newList.Add(_list.Items);
}
newList.IsReadOnly =
true; return newList;}
else return _list;}
Copyright (c) Marimer LLC