PrefetchPath 1:m-1:m

Posts   
 
    
Fishy avatar
Fishy
User
Posts: 392
Joined: 15-Apr-2004
# Posted on: 05-Jul-2005 20:05:28   

Hi,

I have the following tables:

Assignment - 1:m - AssignmentSubSkill - 1:m - Score

I have the following prefetch that works:

        Dim PrefetchPath As IPrefetchPath2 = New PrefetchPath2(CType(EntityType.AssignmentEntity, Integer))
        PrefetchPath.Add(AssignmentEntity.PrefetchPathGroupAssignment)
        PrefetchPath.Add(AssignmentEntity.PrefetchPathAssignmentSubSkill)

I can't prefecth the Score records from the Assignment collection.

I've attempted to add the relationship in the designer but have failed cry

How do I set it up so that I can do the Prefecth?

Thanks,

Fishy

jeffreygg
User
Posts: 805
Joined: 26-Oct-2003
# Posted on: 05-Jul-2005 20:27:19   

Fishy wrote:

Hi,

I have the following tables:

Assignment - 1:m - AssignmentSubSkill - 1:m - Score

I have the following prefetch that works:

        Dim PrefetchPath As IPrefetchPath2 = New PrefetchPath2(CType(EntityType.AssignmentEntity, Integer))
        PrefetchPath.Add(AssignmentEntity.PrefetchPathGroupAssignment)
        PrefetchPath.Add(AssignmentEntity.PrefetchPathAssignmentSubSkill)

I can't prefecth the Score records from the Assignment collection.

I've attempted to add the relationship in the designer but have failed cry

How do I set it up so that I can do the Prefecth?

Thanks,

Fishy

Obvious questions:

  1. Is the PK established in AssignmentSubSkill?
  2. Is a foreign key constraint established between Score and AssignmentSubSkill
  3. What happens when you try to create a custom relation in the Designer?

I believe that prefetching is based on relationships set up in the designer (most of which are created automatically from the foreign key constraints established in the RDBMS). So, get the relationships set up and the prefetching should follow. simple_smile

Jeff...

Fishy avatar
Fishy
User
Posts: 392
Joined: 15-Apr-2004
# Posted on: 05-Jul-2005 21:00:39   

jeffreygg wrote:

Fishy wrote:

Hi,

I have the following tables:

Assignment - 1:m - AssignmentSubSkill - 1:m - Score

I have the following prefetch that works:

        Dim PrefetchPath As IPrefetchPath2 = New PrefetchPath2(CType(EntityType.AssignmentEntity, Integer))
        PrefetchPath.Add(AssignmentEntity.PrefetchPathGroupAssignment)
        PrefetchPath.Add(AssignmentEntity.PrefetchPathAssignmentSubSkill)

I can't prefecth the Score records from the Assignment collection.

I've attempted to add the relationship in the designer but have failed cry

How do I set it up so that I can do the Prefecth?

Thanks,

Fishy

Obvious questions:

  1. Is the PK established in AssignmentSubSkill?
  2. Is a foreign key constraint established between Score and AssignmentSubSkill
  3. What happens when you try to create a custom relation in the Designer?

I believe that prefetching is based on relationships set up in the designer (most of which are created automatically from the foreign key constraints established in the RDBMS). So, get the relationships set up and the prefetching should follow. simple_smile

Jeff...

Thanks Jeff, 1. Yes 2. Yes 3. The second relationship on the Custom m:n Relationship screen only alows for m:1 mine is a 1:n. So I don't have the option of selecting the Score table.

Any ideas?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 05-Jul-2005 21:01:35   

If there is a relation, you could try: instead of:


PrefetchPath.Add(AssignmentEntity.PrefetchPathAssignmentSubSkill)

do


PrefetchPath.Add(AssignmentEntity.PrefetchPathAssignmentSubSkill).SubPath.Add( _
AssignmentSubSkill.PrefetchPathScore)

Frans Bouma | Lead developer LLBLGen Pro
Fishy avatar
Fishy
User
Posts: 392
Joined: 15-Apr-2004
# Posted on: 05-Jul-2005 21:31:45   

Otis wrote:

If there is a relation, you could try: instead of:


PrefetchPath.Add(AssignmentEntity.PrefetchPathAssignmentSubSkill)

do


PrefetchPath.Add(AssignmentEntity.PrefetchPathAssignmentSubSkill).SubPath.Add( _
AssignmentSubSkill.PrefetchPathScore)

That did it. simple_smile So I take it that 1:n - m:1 are canidates for the PrefetchPath and anything else is accessed thru a SubPath?

Thanks,

Fishy

jeffreygg
User
Posts: 805
Joined: 26-Oct-2003
# Posted on: 05-Jul-2005 21:34:50   

Fishy wrote:

jeffreygg wrote:

Fishy wrote:

Hi,

I have the following tables:

Assignment - 1:m - AssignmentSubSkill - 1:m - Score

I have the following prefetch that works:

        Dim PrefetchPath As IPrefetchPath2 = New PrefetchPath2(CType(EntityType.AssignmentEntity, Integer))
        PrefetchPath.Add(AssignmentEntity.PrefetchPathGroupAssignment)
        PrefetchPath.Add(AssignmentEntity.PrefetchPathAssignmentSubSkill)

I can't prefecth the Score records from the Assignment collection.

I've attempted to add the relationship in the designer but have failed cry

How do I set it up so that I can do the Prefecth?

Thanks,

Fishy

Obvious questions:

  1. Is the PK established in AssignmentSubSkill?
  2. Is a foreign key constraint established between Score and AssignmentSubSkill
  3. What happens when you try to create a custom relation in the Designer?

I believe that prefetching is based on relationships set up in the designer (most of which are created automatically from the foreign key constraints established in the RDBMS). So, get the relationships set up and the prefetching should follow. simple_smile

Jeff...

Thanks Jeff, 1. Yes 2. Yes 3. The second relationship on the Custom m:n Relationship screen only alows for m:1 mine is a 1:n. So I don't have the option of selecting the Score table.

Any ideas?

Well, m:n is defined as 1:n - n:1 so as your relationship is 1:n - 1:n I don't believe you can get the "shortcut" m:n relationship defined. I've never tried that before, and I'm hoping I'm helping here. Let me know. But, as Frans said, you should still be able to gain access through the subpath as you said the constraints (and thus the relations) are established.

Jeff...

<Edit> Oops, you just beat me to the reply. Glad it worked.