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