Setting a Relationship Via a FK Int Property

Posts   
 
    
alexk
User
Posts: 19
Joined: 14-Sep-2005
# Posted on: 30-Sep-2005 00:00:49   

(Disclaimer: I'm a newbie to LLBLGenPro.) I have a form where the end user can add new Widgets. The Widget class is associated m-1 to the Foo class, so I'll have a dropdown where the appropriate Foo instance can be chosen. I can simply fetch all the Foo instances to populate the dropdown but suppose I need to display only its name field and not the other 10 columns which may contain a significant amount of unneeded data.

For this scenario, could I simply use a typed list that contained only the Foo ID & name fields? I see that the generated code contains both a Widget.Foo property and also a Widget.FooID property. I couldn't find any discussions about setting Widget.FooID instead of Widget.Foo, and so I'd like to learn whether this is a good approach. A simple test I did seems to indicate it does work, but are there any side effects that would be undesirable? I'd like to ensure there's nothing I've overlooked.

For editing an existing Widget, I would default the Foo dropdown to display the current Widget.FooID value. Are there any non-obvious problems there?

Finally, suppose Widget had an m-m relationship to Foo, then I assume I could: 1. instantiate the WidgetFoo entity that represents the join table and set its two ID fields 2. set Widget.WidgetFoo to that instance 3. do a recursive save

Once again, are there any problems with that approach?

I apologize in advance if info on this topic is available. I did an earnest search through the user docs and also the forums and didn't find anything. Thanks for any help!

Drewes
User
Posts: 67
Joined: 18-Aug-2003
# Posted on: 30-Sep-2005 03:00:12   

Alex, what you propose sounds like the right approach to me, the typed list is intended that what you intend to use it for. Without knowing your db and seeing your code, I would say you are definitely on the right track.