Faster method of moving objects from a temporary cache list to indexed cache lists

This commit is contained in:
Rich
2010-09-29 17:21:30 +00:00
parent f3782ea2a2
commit 9f869343cd
55 changed files with 385 additions and 440 deletions

View File

@@ -91,20 +91,19 @@ namespace VEPROMS.CSLA.Library
private static Dictionary<string, List<ROFst>> _CacheByRODbID_DTS = new Dictionary<string, List<ROFst>>();
private static void ConvertListToDictionary()
{
List<ROFst> remove = new List<ROFst>();
foreach (ROFst tmp in _CacheList)
while (_CacheList.Count > 0) // Move ROFst(s) from temporary _CacheList to _CacheByPrimaryKey
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.ROFstID.ToString()))
ROFst tmp = _CacheList[0]; // Get the first ROFst
string pKey = tmp.ROFstID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[tmp.ROFstID.ToString()] = new List<ROFst>(); // Add new list for PrimaryKey
_CacheByPrimaryKey[pKey] = new List<ROFst>(); // Add new list for PrimaryKey
_CacheByRODbID_DTS[tmp.RODbID.ToString() + "_" + tmp.DTS.ToString()] = new List<ROFst>(); // Add new list for RODbID_DTS
}
_CacheByPrimaryKey[tmp.ROFstID.ToString()].Add(tmp); // Add to Primary Key list
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
_CacheByRODbID_DTS[tmp.RODbID.ToString() + "_" + tmp.DTS.ToString()].Add(tmp); // Unique Index
remove.Add(tmp);
_CacheList.RemoveAt(0); // Remove the first ROFst
}
foreach (ROFst tmp in remove)
RemoveFromCache(tmp);
}
protected static ROFst GetCachedByPrimaryKey(int rOFstID)
{