public static Dictionary<string,List<LookupItem>> dict;
if (dict == null)
{
dict = IsolatedStorage.GetDropDowns();
return dict["Priority"]
}
else
return dict["Priority"];
or
try
{
return dict["Priority"];
}
catch(KeyNotFoundException e)
{
dict = IsolatedStorage.GetDropDowns();
return dict["Priority"];
}
This is a silverlight application, i have dropdowns cached in isolated storage (if i had to query the wcf service for every lookup then the datagrid takes forever to appear, im well aware that dropdowns could become outdated and i have a means of updating the dictionary when new values are added/removed via a callback), in my xaml, i have a converter that converts the Id returned from a dbquery to the related LookupItem object. I know im never supposed to use try's and catch's as part of application logic, but i realy need the fastest possible approach therefore im willing to ignore that architectural no-no. The reason the dictionary would become null is since im storing the dictionary as a static var in an arbitary class, if the user had to hit F5 to refresh the page, the dictionary would lose its values since the xap file is reloaded and my caching page that executes on login would not execute."Priority" contains a of List. LookupItem contains Key/Value that is needed for ComboBoxes and so on.
1) Is a dictionary the most effecient way of storing this information? 2) which of the two approaches will yield the fastest possible return of the List?