internal static IEnumerable<NodeHead> GetNodeHeads(IEnumerable<int> idArray)
{
var nodeHeads = new List<NodeHead>();
var unloadHeads = new List<int>();
foreach (var id in idArray)
{
string idKey = CreateNodeHeadIdCacheKey(id);
var item = (NodeHead)DistributedApplication.Cache.Get(idKey);
if (item == null)
unloadHeads.Add(id);
else
nodeHeads.Add(item);
}
if (unloadHeads.Count > 0)
{
var needsSorting = nodeHeads.Count > 0;
foreach (var head in DataProvider.Current.LoadNodeHeads(unloadHeads))
{
if (head != null)
CacheNodeHead(head, CreateNodeHeadIdCacheKey(head.Id), CreateNodeHeadPathCacheKey(head.Path));
nodeHeads.Add(head);
}
//we need to sort the final list only if we have
//node heads from the cache AND the database too
if (needsSorting)
{
//sort the node heads aligned with the original list
nodeHeads = (from id in idArray
join head in nodeHeads.Where(h => h != null)
on id equals head.Id
where head != null
select head).ToList();
}
}
return nodeHeads;
}
internal static NodeHead GetNodeHeadByVersionId(int versionId)