1 to 1 relationship

Posts   
 
    
misuk11
User
Posts: 15
Joined: 09-May-2007
# Posted on: 09-May-2007 11:29:18   

im new to llblgen so this probably seems like a very basic question. How do I retrive data from 2 table that have a 1 to 1 relationship ? I want to combine the retrived data from both tables into on resultset as I would in standard SQL

eg

SELECT Table1.Col1,Table2.Col1 FROM Table1 INNER JOIN Table2 ON Table1.ID = Table2.ID WHERE (Table1.ID =

Id like to update data as well

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 09-May-2007 17:14:16   

If you want to fetch data from more than one table then you should use a TypedList, or a DynamicList.

But these are readOnly resultsets. Now if you want to update the fetched data, in one condition that you will update data that belongs to one table only, you may use an EntityCollection (mapped to that table), and use the Designer to map the external fields to this entity as "Fields On Related Fields".

JimHugh
User
Posts: 191
Joined: 16-Nov-2005
# Posted on: 09-May-2007 18:19:51   

Isn't this a classic case for using entity inheritance?

Second table with one to one mapping

Employee - Manager?

Where Manager has additional properties but same primary key as Employee?

If so you could map this out in the Designer.

See the docs "Concepts - Entity inheritance"

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39916
Joined: 17-Aug-2003
# Posted on: 10-May-2007 10:21:18   

Actually Employee-Manager isn't always a good choice for inheritance. I used that example in the manual because a lot of people understand it immediately, however it has a weakness: the physical people represented by these entity instances can change 'type' simple_smile A normal employee can be promoted to a manager. This means that all of a sudden an object has to change type. This isn't possible in a strongly typed environment where everything has a set of types at its creation and won't gain any more types during its lifetime.

To solve this, it's often better to use a 'role' which defines the job title, so leave the 1:1 relation as-is, don't make it into an inheritance relation.

Frans Bouma | Lead developer LLBLGen Pro