Root object with multiple child relations

Root object with multiple child relations

Old forum URL: forums.lhotka.net/forums/t/6480.aspx


stiv posted on Sunday, February 22, 2009

Hello everybory,

I´m new to Csla and i have the following situation in my business model i have a root object with multiple child relations so it seems is a lot of code to type.

Looking at the code generation tools i wonder if it is possible to generation an object like the one i`m describing.

If the answer is yes, which one is the right one? If the answer is is no, is there any chance to narrow the building process?

Any help will be appreciated.

Stiv

 

 

 

 

 

 

rsbaker0 replied on Sunday, February 22, 2009

Yes, this is quite possible.

We use a lazy loading technique combined with having a table of all foreign key relationships for the entire database available (as well as what object Type corresponds with each table).

So, if you have a parent child relationship between types P and C, the advent of managed properties has allowed us to do this in one line, that looks something like this.

public BusinessList<C> GetChildList()

{

return GetRelatedList<C>();

}

The relationship table maps parent and child foreign key names between types P and C and can generate the actual SQL to fetch the child lists. If you have multiple relationships to the same table, then there are overrides in which you specify the name of the foreign key field to match up on (as well as even the ability to include conditions for non-standard scenarios)

Copyright (c) Marimer LLC