Faster method of moving objects from a temporary cache list to indexed cache lists
This commit is contained in:
@@ -99,20 +99,19 @@ namespace VEPROMS.CSLA.Library
|
||||
private static Dictionary<string, List<Folder>> _CacheByParentID_Name = new Dictionary<string, List<Folder>>();
|
||||
private static void ConvertListToDictionary()
|
||||
{
|
||||
List<Folder> remove = new List<Folder>();
|
||||
foreach (Folder tmp in _CacheList)
|
||||
while (_CacheList.Count > 0) // Move Folder(s) from temporary _CacheList to _CacheByPrimaryKey
|
||||
{
|
||||
if (!_CacheByPrimaryKey.ContainsKey(tmp.FolderID.ToString()))
|
||||
Folder tmp = _CacheList[0]; // Get the first Folder
|
||||
string pKey = tmp.FolderID.ToString();
|
||||
if (!_CacheByPrimaryKey.ContainsKey(pKey))
|
||||
{
|
||||
_CacheByPrimaryKey[tmp.FolderID.ToString()] = new List<Folder>(); // Add new list for PrimaryKey
|
||||
_CacheByPrimaryKey[pKey] = new List<Folder>(); // Add new list for PrimaryKey
|
||||
_CacheByParentID_Name[tmp.ParentID.ToString() + "_" + tmp.Name.ToString()] = new List<Folder>(); // Add new list for ParentID_Name
|
||||
}
|
||||
_CacheByPrimaryKey[tmp.FolderID.ToString()].Add(tmp); // Add to Primary Key list
|
||||
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list
|
||||
_CacheByParentID_Name[tmp.ParentID.ToString() + "_" + tmp.Name.ToString()].Add(tmp); // Unique Index
|
||||
remove.Add(tmp);
|
||||
_CacheList.RemoveAt(0); // Remove the first Folder
|
||||
}
|
||||
foreach (Folder tmp in remove)
|
||||
RemoveFromCache(tmp);
|
||||
}
|
||||
protected static Folder GetCachedByPrimaryKey(int folderID)
|
||||
{
|
||||
|
Reference in New Issue
Block a user