relations question

Posts   
 
    
mafti23
User
Posts: 13
Joined: 12-Jun-2006
# Posted on: 18-Jul-2006 14:36:51   

Hey there,

i'm trying to achieve how to fetch the collection of a foreign-key. i know a certain field is foreign-key, but how do i know which collection to use to get it all entities from that certain table?

i'm trying to create this in normal code first, then i hope to do it in some of my templates wink

tried to search the forum but it didn't give me "good" answers.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 18-Jul-2006 15:13:37   

Sorry, but I don't quite understand your question? Would you please re-phrase it or elaborate more.

Thanks.

mafti23
User
Posts: 13
Joined: 12-Jun-2006
# Posted on: 18-Jul-2006 15:27:35   

Ok,

i got an entity which has got a FK in it. this has a relation to another table (otherwise it wouldn't be a Foreignkey) what i want is to fetch a collection of the table of that FK.

i already can access the entity with the foreignkey.

sideinfo: i want to "dynamic" create a dropdownlist for that foreign-key.

now i'm doing:

LoadData() {

CreateDropDownListForFoo();
CreateDropDownListForBar();
etc.
}

CreateDropDownListForFoo() {
    FooCollection f = new FooCollection();
   f.getMulti(null)l
  etc. etc.
}

what i kinda want:

LoadData() {

someEntity ent = new someEntity();
if (ent.Fields[x].IsForeignKey) {
      CreateDropDownList(ent.Fields[x]);
}

CreateDropDownList(EntityField field) {
   //getcollection of the table from the field.
// field is foreign-key so it's bound to a table
}

ps. if i can generate this with the template-generator only, that's also cool wink

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 18-Jul-2006 16:23:54   

I think you already know that but there is nothing newer than this: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=2019

mafti23
User
Posts: 13
Joined: 12-Jun-2006
# Posted on: 18-Jul-2006 16:29:44   

Walaa wrote:

I think you already know that but there is nothing newer than this: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=2019

erm yes, so i cannot do it after the code has been generated...

well gonna look how i;m gonna solve it in a template then sunglasses