Faster method of moving objects from a temporary cache list to indexed cache lists

This commit is contained in:
Rich
2010-09-29 17:21:30 +00:00
parent f3782ea2a2
commit 9f869343cd
55 changed files with 385 additions and 440 deletions

View File

@@ -714,12 +714,13 @@ namespace <%=_nameSpace%>
%>
private static void ConvertListToDictionary()
{
List<<%=_className%>> remove = new List<<%=_className%>>();
foreach (<%=_className%> tmp in _CacheList)
while (_CacheList.Count > 0) // Move <%=_className%>(s) from temporary _CacheList to _CacheByPrimaryKey
{
if (!_CacheByPrimaryKey.ContainsKey(<%=pKey%>))
<%=_className%> tmp = _CacheList[0]; // Get the first <%=_className%>
string pKey = <%=pKey%>;
if (!_CacheByPrimaryKey.ContainsKey(pKey))
{
_CacheByPrimaryKey[<%=pKey%>] = new List<<%=_className%>>(); // Add new list for PrimaryKey<%
_CacheByPrimaryKey[pKey] = new List<<%=_className%>>(); // Add new list for PrimaryKey<%
foreach(IIndex ind in uniqueIndexes)
{
string sBy = FormatColumns("{name}",ind.Columns,"_","");
@@ -729,7 +730,7 @@ namespace <%=_nameSpace%>
}
%>
}
_CacheByPrimaryKey[<%=pKey%>].Add(tmp); // Add to Primary Key list<%
_CacheByPrimaryKey[pKey].Add(tmp); // Add to Primary Key list<%
foreach(IIndex ind in uniqueIndexes)
{
string sBy = FormatColumns("{name}",ind.Columns,"_","");
@@ -738,10 +739,8 @@ namespace <%=_nameSpace%>
_CacheBy<%=sBy%>[<%=sKey%>].Add(tmp); // Unique Index<%
}
%>
remove.Add(tmp);
_CacheList.RemoveAt(0); // Remove the first <%=_className%>
}
foreach (<%=_className%> tmp in remove)
RemoveFromCache(tmp);
}<%
if (bInfo && AnyNotOneToOne(_workingTable)) // AddList function for infolist - Any non 1 to 1 relationships
{