I feel stupid, but I do not see ObjectGraphUtils in SD.LLBLGen.Pro.ORMSupportClasses
So, I just wrote this - untested
private List<IEntity> TraverseEntityCollection(IEntityCollection collection)
{
List<IEntity> finalList = new List<IEntity>();
foreach(IEntity eb in collection)
{
finalList.Add(eb);
subTraverseEntityCollection(eb, finalList);
}
return finalList;
}
private void subTraverseEntityCollection(IEntity eb, List<IEntity> finalList)
{
List<IEntity> list1 = eb.GetDependingRelatedEntities();
foreach (IEntity subEB in list1)
{
finalList.Add(subEB);
subTraverseEntityCollection(subEB, finalList);
}
List<IEntityCollection> list2 = eb.GetMemberEntityCollections();
foreach (IEntityCollection sublist in list2)
{
foreach (IEntity subEB in sublist)
{
finalList.Add(subEB);
subTraverseEntityCollection(subEB, finalList);
}
}
}
The problem I see is that I have some entities which refer to themselves. I have the hunch that GetDependingRelatedEntities is going to throw me into infinite recursion. If so, will have to check finalList before adding a node and recursing.