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