codesmithtools / Templates

CodeSmith Generator Templates
http://www.codesmithtools.com/product/generator
54 stars 35 forks source link

CSLA: Not inserting Switchable Grandchild objects #665

Closed GoogleCodeExporter closed 4 years ago

GoogleCodeExporter commented 9 years ago
When you must insert a Child with its Grandchild, and the grandchild is a 
switchable object, the grandchild are not inserted.

Not happening on Update, only when inserting the grandchild.

I had a look to the tamplates and I think that I discovered the cause (on the 
VB templates).

On ChildUpdate.ParametrizedSQL.cst we can see the following lines:

        For Each a As IAssociation In Entity.Associations.Where(Function(assoc) assoc.AssociationType = AssociationType.OneToMany OrElse assoc.AssociationType = AssociationType.ZeroOrOneToMany OrElse assoc.AssociationType = AssociationType.ManyToMany)
             If IsChildBusinessObject(a) Or IsSwitchableObject(a) Then
                 childCount += 1
             End If
         Next

But in ChildInsert.ParametrizedSQL.cst we can see that:

        For Each a As IAssociation In Entity.Associations.Where(Function(assoc) assoc.AssociationType = AssociationType.OneToMany OrElse assoc.AssociationType = AssociationType.ZeroOrOneToMany OrElse assoc.AssociationType = AssociationType.ManyToMany)
            If IsChildBusinessObject(a) Then
                childCount += 1
            End If
        Next

The childCount var is used later to call to FieldManager.UpdateChildren, but 
instead, the following lines are generated in ChildInsert:

            ' A child relationship exists on this Business Object but its type is not a child type (E.G. EditableChild). 
            ' TODO: Please override OnChildInserted() and insert this child manually.
            'FieldManager.UpdateChildren(<%= Entity.BuildUpdateChildrenParametersVariables(true) %>)

I think the correct in ChildInsertParametrizedSQL.cst is to have in account the 
SwitchableObjects, as in ChildUpdateParametrizedSQL.cst.

Original issue reported on code.google.com by bernyrod...@gmail.com on 29 Sep 2012 at 7:58

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 1 Oct 2012 at 1:21

stale[bot] commented 4 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.