Collection Fetching Duplicate Row

Posts   
 
    
bshuman
User
Posts: 24
Joined: 14-Dec-2004
# Posted on: 17-May-2005 20:29:50   

I have a situation where I am getting an unexpected duplicate row in my collection. I have the following tables (simplified):

Organization ...OrgID int

AppUser ...UserID int ...OrgID int

Each user is in one organization. I am using the SelfServicing templates. Here is the senario I wanted to use:

//Create an AppUser object (inherited from AppUserEntity)
AppUser user = new AppUser(1);
//Get collection of available users
AppUserCollection userAvailable = user.Organization.AppUser;

This should give me a list of all users in the current user's (ID=1) organization. It does, except it repeats the current user. Using SQLProfiler I see that the SQL is correct and does not return a duplicate row.

If I do the following (not using inherited class) everything works fine:

//Create an AppUserEntity object
AppUserEntity user = new AppUserEntity(1);
//Get collection of available users
AppUserCollection userAvailable = user.Organization.AppUser;

In either case I end up getting my AppUser Collection from an OrganizationEntity object so I don't understand why I get different results. This is not an emergency since the work around works fine. Thanks.

-Bill Shuman

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 18-May-2005 10:50:29   

Weird simple_smile . What exactly do you do in the inherited class? As it seems the reason it produces a dupe in the collection is located in your inherited class...

Frans Bouma | Lead developer LLBLGen Pro
bshuman
User
Posts: 24
Joined: 14-Dec-2004
# Posted on: 18-May-2005 14:59:44   

I agree that it must be something in the inherited class. I couldn't see anything I was doing to cause it. It's sort of a circular reference in that I am returning a collection of related users from an organization but I'm getting the organization object from a user.
It also add the duplicate when I do the following:

AppUser user = new AppUser(1);
OrganizationEntity org = user.Organization;
userAvailable = org.AppUser;

I hate to take your time looking at this since I have an easy work around. If you are concerned that it might be an obscure bug in LLBLGen then I'd be happy to send you the inherited class code (it's over 700 lines of code).

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 19-May-2005 10:11:57   

bshuman wrote:

I agree that it must be something in the inherited class. I couldn't see anything I was doing to cause it. It's sort of a circular reference in that I am returning a collection of related users from an organization but I'm getting the organization object from a user.
It also add the duplicate when I do the following:

AppUser user = new AppUser(1);
OrganizationEntity org = user.Organization;
userAvailable = org.AppUser;

I hate to take your time looking at this since I have an easy work around. If you are concerned that it might be an obscure bug in LLBLGen then I'd be happy to send you the inherited class code (it's over 700 lines of code).

Well, the fetch logic for the collection fetch first adds all existing entities to a construct to determine duplicates based on the PK. Then it fetches the new objects, and if an entity already was in the collection, it's ignored (based on the PK), so I find it strange that apparently this doesn't work very well in your setup.

I therefore am interested in your derived class, please mail it to support AT llblgen.com (zipped, so outlook doesn't strip it off wink )

Frans Bouma | Lead developer LLBLGen Pro