private List <string> ListMatchingUserName(string startsWith) { // To avoid lots of SQL calls here, we try to make use of caching as best we can // 1. Have we got a cached Dictionary to check yet? Dictionary <string, List <string> > dictionary = Cache[Globals.CacheKeys.UserNameDictionaryCacheEntry] as Dictionary <string, List <string> >; if (null == dictionary) // Create one { dictionary = new Dictionary <string, List <string> >(); } // 2. Do we have an entry in the dictionary already or do we have to fetch and store? List <string> resultList = null; if (dictionary.ContainsKey(startsWith)) { resultList = dictionary[startsWith]; } else { int?orgId = null; OrganisationSettings settings = new OrganisationSettings(); if (!string.IsNullOrEmpty(settings.OrganisationId)) { orgId = Convert.ToInt32(settings.OrganisationId); } resultList = ApartmentMethods.ListUserName(Membership.ApplicationName, orgId, startsWith); dictionary.Add(startsWith, resultList); Cache[Globals.CacheKeys.UserNameDictionaryCacheEntry] = dictionary; } return(resultList); }
public List <string> ListUserName(string applicationName, int?orgId, string startsWith) { return(ApartmentMethods.ListUserName(applicationName, orgId, startsWith)); }