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