Defaults at Factory or constructor or ??

Posts   
 
    
omar avatar
omar
User
Posts: 569
Joined: 15-Oct-2004
# Posted on: 28-Feb-2005 12:32:11   

Urgent

Greetings,

I have the following problem; when using the adapter model with

I have a derived entity class (ICInventory) that inherits ICInventoryEntity (generated by the adapter template), I modified the constructors of the class so that each would call a routine (InitializeObject).

In the this routine I'm initializing the objects' properties with defaults retrieved from the database.

The problem is as follows, on of the objects properties is a collection (ICInventoryStockTotal) that defaults to 10 records (one for each store) when the object is created. When I want ot fetch a collection of the ICInventory object the collection gets populated with objects that have those ten records in addtion to the related records retrieved from the database.

This is a result of the factory of ICInventory calling the constructor with the InitializeObject when retrieving data from the database. Where is the best and recommended area to place this type of initialization code so as to avoid the factory firing unwanted initialization code.

Thanks, Omar

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 28-Feb-2005 13:17:23   

Perhaps it's me (very likely), but I fail to see the problem confused . Your setup adds multiple times those 10 related objects in the collection?

Frans Bouma | Lead developer LLBLGen Pro