Bound typed list and weak relation

Posts   
 
    
JimFoye avatar
JimFoye
User
Posts: 656
Joined: 22-Jun-2004
# Posted on: 07-Dec-2004 16:31:50   

I've bound a typed list at design-time to a grid. It contains a relation mapped to a foreign key that is NOT NULL, so I want to be a weak relation so it will retrieve all records.

I changed this generated code

             this.locationsTypedList1.ObeyWeakRelations = false;

to

             this.locationsTypedList1.ObeyWeakRelations = true;

but that didn't work. I'm guessing that I actually need to tell it specifically that this relation is weak? I didn't see a place to do that in the designer when I was creating the typed list, and I have searched the manual to no avail. (I do always try to search the manual first before posting to the forum).

Any ideas? Demo in 30 minutes!! Ha ha!! But this won't kill the demo if it doesn't work.

JimFoye avatar
JimFoye
User
Posts: 656
Joined: 22-Jun-2004
# Posted on: 07-Dec-2004 16:38:41   

Sometimes I think I'm going insane. Either that or there is something seriously goofy with VS Studio.

I just set the foreign key value in a few records to something so that some records would show up in my demo. I run the program and, wa la! all the records show up, which means that it appears to be observing that ObeyWeakRelations flag.

Anyway, this does raise an interesting question of semantics. Does ObeyWeakRelations mean:

1) Obey relations that are weak (each relation must be strong or weak)

2) Treat all relations as weak

Please point me to place in manual that clarifies this if you can.

Thanks in advance.

Jim

(Edited because English is my first language, therefore anything I write in English should be grammatically correct).

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39615
Joined: 17-Aug-2003
# Posted on: 07-Dec-2004 17:07:14   

Option 1), treat relations which are weak as weak, which is a shortcut to use LEFT JOINs on 1:n relations for example.

Set the option before you call Fill()

Frans Bouma | Lead developer LLBLGen Pro
JimFoye avatar
JimFoye
User
Posts: 656
Joined: 22-Jun-2004
# Posted on: 07-Dec-2004 18:26:08   

OK, thanks. But how do I designate a relation as weak? I didn't see this in the designer, and I didn't see anything in Intellisense that seemed to be what I'm looking for.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39615
Joined: 17-Aug-2003
# Posted on: 07-Dec-2004 19:20:15   

JimFoye wrote:

OK, thanks. But how do I designate a relation as weak? I didn't see this in the designer, and I didn't see anything in Intellisense that seemed to be what I'm looking for.

A relation is weak if the related entity is optional.

A 1:n B: A->B is weak, B->A is strong if B's FK is not nullable, otherwise weak A 1:1 B (fk): A->B is weak, B-> is strong.

Joinhints have been implemented in the core code (so you can create a dynamic list with all right joins if you want to), but not in the designer yet. That is in development now.

Frans Bouma | Lead developer LLBLGen Pro
JimFoye avatar
JimFoye
User
Posts: 656
Joined: 22-Jun-2004
# Posted on: 07-Dec-2004 21:40:00   

Ok, now I think I understand. I don't deem the relation to be weak, is weak if the FK is declared as NULL. Then the property setting determines if RIGHT JOINs will be used. Yes?

Thanks.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39615
Joined: 17-Aug-2003
# Posted on: 08-Dec-2004 09:21:16   

JimFoye wrote:

Ok, now I think I understand. I don't deem the relation to be weak, is weak if the FK is declared as NULL. Then the property setting determines if RIGHT JOINs will be used. Yes? Thanks.

The setting was introduced to avoid having to set for each relation how the join type would be, as you have in general just 2 types of joins: an inner join and an outer join. inner joins don't include optional data, outer joins do. Inner join is the default, so if the developer wants to have optional data, an outer join should be used. Typically, once you introduce an outerjoin in the join list, the data joined via the outer join is in theory optional, so you can simply use one setting.

Because it was hard to understand what it actually did, what hte relations would be, I introduced the joinhints in 1.0.2004.1 of the runtimes. The designer doesn't have them yet, but very soon they'll be included into the designer as well (for typed lists). So see the obeyweakrelations setting as a convenience property to make the joins include optional data instead of inner joins. It sometimes uses RIGHT joins, it sometimes uses LEFT joins, depending on the direction of the relation simple_smile .

Frans Bouma | Lead developer LLBLGen Pro