Child Collection Entity has extra row when first created

Posts   
 
    
EdL
User
Posts: 51
Joined: 01-Mar-2010
# Posted on: 29-Jul-2010 17:17:13   

I have an Entity (Parent) with a 1:m relationship with another (Child)

When created, Parent is created and saved then, all the Child entries are created new, saved and then added to the collection then, the Parent is then updated with a sum value from the Child records and, saved again

All seems fine in the database... there are 228 child records and the sum field in the parent equals the sum of the fields in the Child records.

But... if use the just created instance of the Parent and ForEach the Child recrods in the Children collection there are 229 records, one greater than the expected 228. Note: the first record is repeated.

And... if I create an new instance of the Parent by creating from the database... everything is fine and there are 228 records in the Child collection.

What am I screwing up? disappointed

Thanks,

Ed

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 29-Jul-2010 21:52:22   

Could you post the code you are using - it's much easier to see what you are screwing up with it... simple_smile

Matt