Faster method of moving objects from a temporary cache list to indexed cache lists
This commit is contained in:
@@ -65,18 +65,17 @@ namespace VEPROMS.CSLA.Library
|
||||
private static Dictionary<string, List<Membership>> _CacheByPrimaryKey = new Dictionary<string, List<Membership>>();
|
||||
private static void ConvertListToDictionary()
|
||||
{
|
||||
List<Membership> remove = new List<Membership>();
|
||||
foreach (Membership tmp in _CacheList)
|
||||
while (_CacheList.Count > 0) // Move Membership(s) from temporary _CacheList to _CacheByPrimaryKey
|
||||
{
|
||||
if (!_CacheByPrimaryKey.ContainsKey(tmp.UGID.ToString()))
|
||||
Membership tmp = _CacheList[0]; // Get the first Membership
|
||||
string pKey = tmp.UGID.ToString();
|
||||
if (!_CacheByPrimaryKey.ContainsKey(pKey))
|
||||
{
|
||||
_CacheByPrimaryKey[tmp.UGID.ToString()] = new List<Membership>(); // Add new list for PrimaryKey
|
||||
_CacheByPrimaryKey[pKey] = new List<Membership>(); // Add new list for PrimaryKey
|
||||
}
|
||||
_CacheByPrimaryKey[tmp.UGID.ToString()].Add(tmp); // Add to Primary Key list
|
||||
remove.Add(tmp);
|
||||
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
|
||||
_CacheList.RemoveAt(0); // Remove the first Membership
|
||||
}
|
||||
foreach (Membership tmp in remove)
|
||||
RemoveFromCache(tmp);
|
||||
}
|
||||
protected static Membership GetCachedByPrimaryKey(int ugid)
|
||||
{
|
||||
|
Reference in New Issue
Block a user