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<Role>> _CacheByName = new Dictionary<string, List<Role>>();
|
||||
private static void ConvertListToDictionary()
|
||||
{
|
||||
List<Role> remove = new List<Role>();
|
||||
foreach (Role tmp in _CacheList)
|
||||
while (_CacheList.Count > 0) // Move Role(s) from temporary _CacheList to _CacheByPrimaryKey
|
||||
{
|
||||
if (!_CacheByPrimaryKey.ContainsKey(tmp.RID.ToString()))
|
||||
Role tmp = _CacheList[0]; // Get the first Role
|
||||
string pKey = tmp.RID.ToString();
|
||||
if (!_CacheByPrimaryKey.ContainsKey(pKey))
|
||||
{
|
||||
_CacheByPrimaryKey[tmp.RID.ToString()] = new List<Role>(); // Add new list for PrimaryKey
|
||||
_CacheByPrimaryKey[pKey] = new List<Role>(); // Add new list for PrimaryKey
|
||||
_CacheByName[tmp.Name.ToString()] = new List<Role>(); // Add new list for Name
|
||||
}
|
||||
_CacheByPrimaryKey[tmp.RID.ToString()].Add(tmp); // Add to Primary Key list
|
||||
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
|
||||
_CacheByName[tmp.Name.ToString()].Add(tmp); // Unique Index
|
||||
remove.Add(tmp);
|
||||
_CacheList.RemoveAt(0); // Remove the first Role
|
||||
}
|
||||
foreach (Role tmp in remove)
|
||||
RemoveFromCache(tmp);
|
||||
}
|
||||
protected static Role GetCachedByPrimaryKey(int rid)
|
||||
{
|
||||
|
Reference in New Issue
Block a user