Using outer joins

Posts   
 
    
HcD avatar
HcD
User
Posts: 214
Joined: 12-May-2005
# Posted on: 23-May-2005 01:21:36   

Hi,

a new challenge simple_smile Suppose i have the following setup: A language table with a language code (1033 for english, 1036 for french, 1043 for dutch, ...) I have then an entity "Entity" with a 1:n relation to the EntityLocale table, which has 3 fields : entity_id, lang_code, entity_description.

What i want now is to fetch a collection EntityLocaleCollection for a specified EntityId, with a record for EACH possible languages in the language table, not only the ones that allready exist

For example, assume we have an Entity with id 1 with the following records in the EntityLocale Table 1 - 1033 - My description 1 - 1043 - Mijn Omschrijving

What i want, when the language table holds 3 languagues (1043,1033,1036), is the following collection returned: 1 - 1033 - My Description 1 - 1043 - Mijn omschrijving 1 - 1036 - <NULL>

How can i do this quick an simple (with an outer join i suppose) ? I just KNOW llbl is so good it must be possible, but i just don't see it. Last night i put something together to solve this, but it is so ugly, you don't wanna know, it involves a nested foreach flushed

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 23-May-2005 11:40:23   

Isn't that the same as: select * from EntityLocale left join languages on entitylocale.lang_code =languages.lang_code

?

Entitycollection's fetch existing data. If you want to have a list which is the result of a join as the one above, you should use a typed list or a dynamic list.

Frans Bouma | Lead developer LLBLGen Pro