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