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