Double Record Return

Posts   
 
    
ianvink
User
Posts: 394
Joined: 15-Dec-2006
# Posted on: 18-Jul-2007 18:58:07   

I have a customer table with 2 customers. The linked Orders table has only 1 order. (fresh DB)

When I add a prefetch and select all the customers, I get 2 orders. They are copies of the same order (OrderPK is the same)

So CustomerCollection[0].OrderCollection.Count = 2

I use this code.

IPrefetchPath path = new PrefetchPath((int)EntityType.CustomerEntity);
path.Add(CustomerEntity.PrefetchPathOrderCollection);

myCustomerCollection.GetMulti(null,path);

The join is Orders.CustomerFK = Customers.CustomerPK. Very simple.

When I don't send in the path to GetMulti() I get correctly 1 order and everything works great in the app.

Ideas?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 19-Jul-2007 03:48:40   

Couple of questions:

  1. What's the value of myCustomerCollection[0].OrderCollection.Count before GelMulti?

  2. What LLBLGen version are you using?

David Elizondo | LLBLGen Support Team
ianvink
User
Posts: 394
Joined: 15-Dec-2006
# Posted on: 19-Jul-2007 12:25:24   

Hi David,

I called clear() on the collection before GetMulti().

My signature has the specs on the dev environment.

Cheers, Ian

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 19-Jul-2007 15:21:45   

Would you please examine the generated queries and run them directly against the database to see if they return the expected results?

I called clear() on the collection before GetMulti().

Would you please post complete re-pro code?

Make sure the order collection is not LazyLoaded before it was prefetched. Otherwise you may set the DoNotPerformAddIfPresent collection property to true.