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