ProduceTopologyOrderedList bug?

Posts   
 
    
JayBee
User
Posts: 275
Joined: 28-Dec-2006
# Posted on: 13-Nov-2011 23:12:32   

Hi,

I am not sure if this is a bug or a featuredisappointed

I am using SelfServicing and llblgen 2.6 (latest version).

I'm using some code you can find in the forums whene you search for Deep Copy (i.e. the CloneHelper). Somewhere in this code a graph is built using the ProduceTopologyOrderedList from ObjectGraphUtils. The graph that is built only contains the root entity and no children.

Here is the code


        public static IEntity CloneEntity(IEntity Entity, bool ResetAsNew)
        {
            IEntity newEntity;
            newEntity = (IEntity)CloneObject(Entity);
            ObjectGraphUtils ogu = new ObjectGraphUtils();
            List<IEntity> flatList = ogu.ProduceTopologyOrderedList(newEntity);

            if (ResetAsNew)
                for (int f = 0; f < flatList.Count; f++)
                    ResetEntityAsNew(flatList[f]);

            return newEntity;
        }

When I use a breakpoint at the line that declare the ObjectGraphUtils variable ogu and browse the newEntity, the graph contains both the root entity and the children

Could this have something to do with lazy loading? Is there a way to force the ProduceTopologyOrderedList to present the complete graph?

Best regards,

Jan

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 14-Nov-2011 09:40:53   

AFAIK, the ProduceTopologyOrderedList() should return the complete graph.

Which LLBLGenPro runtime library version (build no.) are you using?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 14-Nov-2011 10:28:42   

JayBee wrote:

Hi,

I am not sure if this is a bug or a featuredisappointed

I am using SelfServicing and llblgen 2.6 (latest version).

I'm using some code you can find in the forums whene you search for Deep Copy (i.e. the CloneHelper). Somewhere in this code a graph is built using the ProduceTopologyOrderedList from ObjectGraphUtils. The graph that is built only contains the root entity and no children.

Here is the code


        public static IEntity CloneEntity(IEntity Entity, bool ResetAsNew)
        {
            IEntity newEntity;
            newEntity = (IEntity)CloneObject(Entity);
            ObjectGraphUtils ogu = new ObjectGraphUtils();
            List<IEntity> flatList = ogu.ProduceTopologyOrderedList(newEntity);

            if (ResetAsNew)
                for (int f = 0; f < flatList.Count; f++)
                    ResetEntityAsNew(flatList[f]);

            return newEntity;
        }

When I use a breakpoint at the line that declare the ObjectGraphUtils variable ogu and browse the newEntity, the graph contains both the root entity and the children

Could this have something to do with lazy loading? Is there a way to force the ProduceTopologyOrderedList to present the complete graph?

The method produces a sorted list (topologically sorted, so it sorts the graph in dependency order) of entities currently in memory. When you browse to the entity in the debugger and step to a property which is a related entity, the debugger simply calls the 'get' of the property which triggers lazy loading indeed.

The method works as expected (otherwise the save mechanism in the runtime wouldn't work wink )

Frans Bouma | Lead developer LLBLGen Pro
JayBee
User
Posts: 275
Joined: 28-Dec-2006
# Posted on: 14-Nov-2011 18:36:37   

Oké Frans.

As a consequence this method cannot be used to copy an entity and the related entities (grandparent - parent - children - etc) unless you access all related entities somewhere in the code.

Is there another method in LLBLGen to achieve this?

Best regards,

Jan

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 15-Nov-2011 06:57:56   

JayBee wrote:

As a consequence this method cannot be used to copy an entity and the related entities (grandparent - parent - children - etc) unless you access all related entities somewhere in the code.

If the related entities are already fetched, the method will peak all the in-memory related ones. So, you can prefetch all the related entities you want before call the copy routine.

David Elizondo | LLBLGen Support Team