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

@@ -48,18 +48,17 @@ namespace VEPROMS.CSLA.Library
private static Dictionary<string, List<RODbInfo>> _CacheByPrimaryKey = new Dictionary<string, List<RODbInfo>>();
private static void ConvertListToDictionary()
{
List<RODbInfo> remove = new List<RODbInfo>();
foreach (RODbInfo tmp in _CacheList)
while (_CacheList.Count > 0) // Move RODbInfo(s) from temporary _CacheList to _CacheByPrimaryKey
{
if (!_CacheByPrimaryKey.ContainsKey(tmp.RODbID.ToString()))
RODbInfo tmp = _CacheList[0]; // Get the first RODbInfo
string pKey = tmp.RODbID.ToString();
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[tmp.RODbID.ToString()] = new List<RODbInfo>(); // Add new list for PrimaryKey
_CacheByPrimaryKey[pKey] = new List<RODbInfo>(); // Add new list for PrimaryKey
}
_CacheByPrimaryKey[tmp.RODbID.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 RODbInfo
}
foreach (RODbInfo tmp in remove)
RemoveFromCache(tmp);
}
internal static void AddList(RODbInfoList lst)
{