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