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