Prefetch problem

Posts   
 
    
davisg avatar
davisg
User
Posts: 113
Joined: 27-Feb-2005
# Posted on: 25-Feb-2008 15:36:15   

I have 4 Tables

MusicArtist MusicArtistGenre MusicArtistRelationship MusicGenre

MusicArtist has PK of ArtistID MusicArtistGenre has PK of ArtistGenreID and FK of ArtistID (Linked to MusicArtist) and GenreID (Linked to MusicGenre) MusicArtistRelationship has PK of ArtistRelationshipID and KF or ArtistID1 (Linked to MusicArtist) and ArtistID2 (Linked to MusicArtist) MusicGenre has PK of GenreID

When I generate the code it creates MusicArtistEntity.MusicGenreCollectionViaMusicArtistGenre but it does not create anything like MusicArtistEntity.MusicArtistCollectionViaMusicArtistRelationship and MusicArtistEntity.MusicArtistCollectionViaMusicArtistRelationship_ (or something like that) so i'm having problems binding this prefetch list of MusicArtistEntity to a grid because i'm not sure what to use for the syntax.

The way I get the main MusicArtistEntity record with prefetch is like so:


Dim DB as IDataAccessAdapter = Ctype(GetAccessAdapter(DatabaseType.SQLServer), IDataAccessAdapter)
Dim PK as Integer = 1
Dim path as IPrefetchPath2 = new PrefetchPath2(Ctype(EntityType.MusicArtistEntity,Integer))
path.Add(MusicArtistEntity.PrefetchPathMusicArtistRelationship).SubPath.Add(MusicArtistRelationshipEntity.PrefetchPathMusicArtist_)
path.Add(MusicArtistEntity.PrefetchPathMusicGenreCollectionViaMusicArtistGenre)
Record = New MusicArtistEntity(Me.PK)
DB.FetchEntity(Record, prefetchPath)

Now I can see via the Diagnostic output that the MusicArtistEntity records are being prefetched correctly for each MusicArtistRelationship in MusicArtistEntity.

The Genre grid is straight forward:

grid1.DataSource = Record.MusicGenreCollectionViaMusicArtistGenre

What should I bind Relationship grid too using this prefetch? or do I have to go about it another way. I was hoping that I didn't need to build another EntityCollection and fill it in if I could get the data via the main records prefetch path.

Hope this makes sense.

Geoff.

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 25-Feb-2008 18:25:49   

Could you please check at LLBLGenPro Desginer if that Entity has some m:n relations hidden?

davisg avatar
davisg
User
Posts: 113
Joined: 27-Feb-2005
# Posted on: 25-Feb-2008 20:39:11   

goose wrote:

Could you please check at LLBLGenPro Desginer if that Entity has some m:n relations hidden?

Nope they are not hidden from what I can tell. See screen shot.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 27-Feb-2008 14:18:25   

Looking into it. Please post these kind of problems in more appropriate forums next time simple_smile (Architecture has a lower priority in our helpdesk queues)

The cause is that it's a m:n with self, and those aren't supported, as they create cycles, and could cause an explosion in the # of m:n relations detected.

An m:n relation is a readonly 'view' on a situation. if you want to bind the artists a given artist is related to, you have to do a manual fetch using an entity collection.

Frans Bouma | Lead developer LLBLGen Pro