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