zengcheng / codesmith

Automatically exported from code.google.com/p/codesmith
0 stars 0 forks source link

BLB + Saving new records issue #328

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. See post at http://forums.lhotka.net/forums/p/8728/41486.aspx#41486

What is the expected output? What do you see instead?
Not sure what the likely change is here. I think it's a CSLA bug, but I
just wanted to let you know of the issue as it might affect Codesmith users.

What version of the product are you using?
v2.0.1.1539

Original issue reported on code.google.com by JenasysD...@gmail.com on 26 Mar 2010 at 7:14

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 26 Mar 2010 at 12:12

GoogleCodeExporter commented 9 years ago
Blake,
Its a codesmith template issue. The save methodology in the DataPortal_Update 
method
isn't CSLA compliant.  Easy fix.

Protected Overrides Sub DataPortal_Update()
        Dim cancel As Boolean = False
        OnUpdating(cancel)
        If (cancel) Then
            Return
        End If

        RaiseListChangedEvents = False

        '   Current template code
        'For Each item As Consultant In Items
        '    item.Save()
        'Next
        '   Suggested template code.
        For myLoop As Integer = 0 To Me.Items.Count - 1
            Me.Items.Item(myLoop) = Me.Items.Item(myLoop).Save()
        Next

        RaiseListChangedEvents = True

        OnUpdated()
    End Sub

Original comment by JenasysD...@gmail.com on 26 Mar 2010 at 9:08

GoogleCodeExporter commented 9 years ago
Attached Is the updated template that resolves the issue for VB.net.

Original comment by JenasysD...@gmail.com on 28 Mar 2010 at 11:41

Attachments:

GoogleCodeExporter commented 9 years ago
Blake,
I've run an nunit test over the code, with the following results. Note, the code
would save the record to the database, but wouldn't correctly populate PK 
Identity
properties in you Business object after the save, which isn't optimal.

        '   CSLA 3.8.2 Failed to raise results back to the object. 
        'For Each item As Consultant In Items
        '    item = item.Save()
        'Next
        '   The following code however does work as expected
        For myloop As Integer = 0 To Items.Count - 1
            Items.Item(myloop) = Items.Item(myloop).Save()
        Next

I've attached a VB fix to the templates.  I think you might also want to review,
(DataPortalUpdate*.cst for "item = item.Save()"), code to ensure that it's 
correctly
executing (I have my doubts) based on my unit tests. 

Original comment by JenasysD...@gmail.com on 29 Mar 2010 at 1:46

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 15 Apr 2010 at 2:35

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 21 Jun 2010 at 8:10