PrefetchPath produces duplicates

Posts   
 
    
Kazak1
User
Posts: 39
Joined: 30-May-2006
# Posted on: 14-Jul-2006 20:16:32   

I recently switched to LLBLGen 2 and it looks like the following code's behavior changed. Now it populates childEntity.Parent.ChildCollection with duplicated ChildEntity 12345.

ChildEntity childEntity = new ChildEntity(12345);
IPrefetchPath2 prefetchPath = new PrefetchPath2((int)EntityType.ChildEntity);
prefetchPath.Add(ChildEntity.PrefetchPathParent).SubPath.Add(ParentEntity.PrefetchPathChildCollection);
using (DataAccessAdapter adapter = new DataAccessAdapter())
{
     adapter.FetchEntity(childEntity, prefetchPath);
}

Is this change intentional?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 14-Jul-2006 20:19:48   
Frans Bouma | Lead developer LLBLGen Pro
Kazak1
User
Posts: 39
Joined: 30-May-2006
# Posted on: 14-Jul-2006 20:46:23   

Found a workaround:


ChildEntity childEntity = new ChildEntity(12345);
IPrefetchPath2 prefetchPath = new PrefetchPath2((int)EntityType.ChildEntity);
prefetchPath.Add(ChildEntity.PrefetchPathParent).SubPath.Add(
          ParentEntity.PrefetchPathChildCollection, 
          0, 
          new PredicateExpression(ChildFields.Id != 12345));
using (DataAccessAdapter adapter = new DataAccessAdapter())
{
     adapter.FetchEntity(childEntity, prefetchPath);
}