Lookups and the way to go

Posts   
 
    
davisg avatar
davisg
User
Posts: 113
Joined: 27-Feb-2005
# Posted on: 31-Mar-2005 11:31:39   

Hi All,

I have tried to look for this info in the forums and i'm sure it is there but I can't find it.

I have a table called Artist and the Artist has a relationship with ArtistRelated. Both tables are displayed below:

Artist

ArtistID PK int Name string

ArtistRelated

ArtistID PK int RelatedID PK int

The RelatedID is an ArtistID in the table Artist, self referencing as so to speak.

In my form I read the entity like below and set the datagrid to it's relationship like so:

ArtistEntity artist = new ArtistEntity(477707); gridControl1.DataSource = artist.GetMultiArtistRelationship(true);

Now this works great and I get my grid filled with ArtistID and RelatedID like so:

ArtistID RelatedID 477707 583483 477707 383834 477707 383894

What I want to do is fill my grid with the Artist Name associated with the RelatedID. Do I have to do through the collection one at a time and read the entity Artist for the Name; if so how does do I do that? or is there a better way?

A code snippet would be great if possible as I will be doing this a lot. wink

Thanks in advance.

Geoff.

Mountain
User
Posts: 21
Joined: 01-Apr-2005
# Posted on: 01-Apr-2005 20:03:54   

davisg wrote:

Hi All,

I have tried to look for this info in the forums and i'm sure it is there but I can't find it.

I have a table called Artist and the Artist has a relationship with ArtistRelated. Both tables are displayed below:

Artist

ArtistID PK int Name string

ArtistRelated

ArtistID PK int RelatedID PK int

The RelatedID is an ArtistID in the table Artist, self referencing as so to speak.

In my form I read the entity like below and set the datagrid to it's relationship like so:

ArtistEntity artist = new ArtistEntity(477707); gridControl1.DataSource = artist.GetMultiArtistRelationship(true);

Now this works great and I get my grid filled with ArtistID and RelatedID like so:

ArtistID RelatedID 477707 583483 477707 383834 477707 383894

What I want to do is fill my grid with the Artist Name associated with the RelatedID. Do I have to do through the collection one at a time and read the entity Artist for the Name; if so how does do I do that? or is there a better way?

A code snippet would be great if possible as I will be doing this a lot. wink

Thanks in advance.

Geoff.

I just posted a similar question. Here's the reply I received:

M:n relations with self are currently not supported (in 1.0.2004.1). If you want I can switch it on in 1.0.2004.2. It was disabled because the runtime engine couldn't alias in the past (before 1.0.2004.1, which wasn't a gui update).

Though as with all relations with self, as you're working on the same table, queries could be more optimial if you simply specify the filters yourself.

My post is here: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=2709