ChildList parent property

7 views
Skip to first unread message

pandelis

unread,
Nov 16, 2009, 10:46:58 AM11/16/09
to CslaGenerator
i am having a weird problem when using any ChildList's (cslagen)
parent properties.When i create a new childlist and either i define
that field, or it is defined by the generator , the parent properties
field affects the generated stored procedure in such a way that the
generated procedure (insert and update) contains double reference to
the parent's table key. Lets see an example.

I have set up my database in such a way that follows the pattern of
order - order details. The order details table holds the foreign key
of the parent table primary key. The relationship is all set between
them properly at the datatable diagram. The resulting generated stored
procedures will hold a double reference to the primary table key
field.

There is another issue when combined with the dataset loading scheme .
If i remove the parent properties entry from the ChildList, the
relationships between the datasets are not generated at all.

Am i doing sth totally wrong here?

Andrés Villanueva

unread,
Nov 16, 2009, 11:00:47 AM11/16/09
to cslage...@googlegroups.com
The child object should not contain the fk property. That is given by
it's parent relationship. Adding that property to the child object
opens the door to big trouble, because you could potentially have a
root object with ID = 26 and set the fk in the child object to, say,
27.

So, remove the FK property from the child object and let that be
determined by the parent object and you should be fine. This will also
solve your other issue with the dataset.

(Hint: when creating child collections, select all columns in the
table except for the root's FK. Then right click and choose Create ->
Child Collection.)
> --
> http://groups.google.com/group/CslaGenerator
> Post to: CslaGe...@googlegroups.com
> Unsuscribe: CslaGenerato...@googlegroups.com
> Join us on #CslaGenerator @ irc.freenode.net



--
Andrés

pandelis

unread,
Nov 16, 2009, 1:20:18 PM11/16/09
to CslaGenerator
Thank you Andres. Should work fine now

Marcos Vinícius

unread,
Nov 26, 2009, 1:27:48 PM11/26/09
to CslaGenerator
Hi there,

I'm trying to avoid this same problem (having the parent's FK in the
child objects).

So I got your idea, Andre, and it sounds like it should work, except
that I can't find any right-click-menu option which says Create ->
*Child Collection*. I have got Read Only Collection, Editable Root
Collection, Editable Child Collection and Name Value List.

Do you mean the Editable Child Collection? Or a Read Only Collection?
My scenario is: I want to be able to show a DataGrid with a list of
Cities. The City Table is connected to a State Table through a column
named "fkState". How would I expose the State Name property? I don't
want to present the GUID (fkState) to the user.

I've been working with CSLA for 2,5 years now but just realized I've
underused it. So many features and I just ignore them.

Sorry if I seem a bit stupid. =)

Cheers,

On 16 nov, 14:00, Andrés Villanueva <xal1...@gmail.com> wrote:
> Thechildobject should not contain the fkproperty. That is given by
> it'sparentrelationship. Adding thatpropertyto thechildobject
> opens the door to big trouble, because you could potentially have a
> root object with ID = 26 and set the fk in thechildobject to, say,
> 27.
>
> So, remove the FKpropertyfrom thechildobject and let that be
> determined by theparentobject and you should be fine. This will also
> solve your other issue with the dataset.
>
> (Hint: when creatingchildcollections, select all columns in the

Andrés Villanueva

unread,
Nov 26, 2009, 2:17:09 PM11/26/09
to cslage...@googlegroups.com
Well, assuming you want to have it in a readonly fashion:

If you want a single grid with no hierarchy:
-Create a readonly collection from the city table
-Select the state table, and the statename column inside it and add it to the readonly item.
That's it for this one.

If you want a hierarchy like a list of states where each state item contains a child list of cities then:
-Create a readonly collection for states (StateList & StateListItem).
-Create another readonly collection for cities (CityList & CityListItem) (excluding StateFK column).
-Set the parent type for CityList to StateListItem. *
-Edit the StateListItem child collection properties and add a new one. *
-Set the ItemType to CityList and specify a name for the property (ie: Cities). *
-You need to set all of the 4 classes to be DataSetLoadingScheme  = True. (This is because we have collections inside collections).

Hope that helped!

Note: for editable child collections the steps marked with a "*" are not necessary, you can select the columns for the child collection, then right click -> create editable child collection and it will ask you the parent type, property name and collection & item type names.





2009/11/26 Marcos Vinícius <marcos...@gmail.com>



--
Andrés

Marcos Vinícius

unread,
Nov 26, 2009, 3:15:00 PM11/26/09
to CslaGenerator
Helped a lot, surely.

I'll give it a try.

On 26 nov, 17:17, Andrés Villanueva <xal1...@gmail.com> wrote:
> Well, assuming you want to have it in a readonly fashion:
>
> If you want a single grid with no hierarchy:
> -Create a readonly collection from the city table
> -Select the state table, and the statename column inside it and add it to
> the readonly item.
> That's it for this one.
>
> If you want a hierarchy like a list of states where each state item contains
> a child list of cities then:
> -Create a readonly collection for states (StateList & StateListItem).
> -Create another readonly collection for cities (CityList & CityListItem)
> (excluding StateFK column).
> -Set the parent type for CityList to StateListItem. *
> -Edit the StateListItem child collection properties and add a new one. *
> -Set the ItemType to CityList and specify a name for the property (ie:
> Cities). *
> -You need to set all of the 4 classes to be DataSetLoadingScheme  = True.
> (This is because we have collections inside collections).
>
> Hope that helped!
>
> Note: for editable child collections the steps marked with a "*" are not
> necessary, you can select the columns for the child collection, then right
> click -> create editable child collection and it will ask you the parent
> type, property name and collection & item type names.
>
> 2009/11/26 Marcos Vinícius <marcosacci...@gmail.com>
Reply all
Reply to author
Forward
0 new messages