Associating Tables

Posts   
 
    
nero2001
User
Posts: 8
Joined: 10-Oct-2006
# Posted on: 10-Oct-2006 17:49:39   

Hi there,

i have 2 tables: User and Account, with a M-1 relation. So, each User has to correspond to an Account.

If i want to associate an User to an Account, can i do this: userObject.AccountId = Id;

or do i need to have the object Account and then: userObject.Account = accountObject;

???

thans in advance simple_smile

Jessynoo avatar
Jessynoo
Support Team
Posts: 296
Joined: 19-Aug-2004
# Posted on: 10-Oct-2006 18:25:39   

Hi,

both methods should work well.

Now, if you have your account entity/collection to hand, you may prefer the second one since it does all the inner plumbings which may for instance allow you to save all your users recursively in a single call to save your account collection.

I also usually prefers userObject.Account = accountObject than accountObject.User.Add(userObject) since it does update both sides and corresponds to the natural action, though I reckon it's permitted to increment the collection since a few releases.

Cheers

nero2001
User
Posts: 8
Joined: 10-Oct-2006
# Posted on: 10-Oct-2006 20:13:32   

Thanks smile