Managed child BO property - DataPortal update failing

Managed child BO property - DataPortal update failing

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


ajj3085 posted on Wednesday, July 16, 2008

Hi,

I have a managed property, which is a child BO instance.  I register it like this in the parent object:
private static readonly PropertyInfo<DepartmentPhoneNumber> PhoneNumberProperty =
            RegisterProperty<DepartmentPhoneNumber>( new PropertyInfo<DepartmentPhoneNumber>( "PhoneNumber" ) );

In the parent's DataPortal_Insert, I try to update the child via this call:
DataPortal.UpdateChild( PhoneNumberProperty, dept );

In the child BO, I have the method:
        private void Child_Update( Data.Contacts.Department dept ) {
            Data.Shared.Phone result;

            result = PhoneData.Update( this );

            if ( ReadProperty( TypeProperty ) == "Office" ) {
                dept.Phone = result;
            }
            else {
                dept.Fax = result;
            }
        }

The problem is that on the DataPortal.UpdateChild call it complains that Child_Update is not implemented.  Any ideas?

Thanks
Andy

ajj3085 replied on Wednesday, July 16, 2008

Opps... I found it:

It should be:
DataPortal.UpdateChild(
     ReadProperty( PhoneNumberProperty ),
     dept
);

sergeyb replied on Wednesday, July 16, 2008

Not sure if this is correct, but your signatures do not match.  .UpdateChild call takes two paramenters, Update_Child only takes one…

 

 

Sergey Barskiy

Senior Consultant

office: 678.405.0687 | mobile: 404.388.1899

Magenic ®

Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: ajj3085 [mailto:cslanet@lhotka.net]
Sent: Wednesday, July 16, 2008 9:43 AM
To: Sergey Barskiy
Subject: [CSLA .NET] Managed child BO property - DataPortal update failing

 

Hi,

I have a managed property, which is a child BO instance.  I register it like this in the parent object:
private static readonly PropertyInfo<DepartmentPhoneNumber> PhoneNumberProperty =
            RegisterProperty<DepartmentPhoneNumber>( new PropertyInfo<DepartmentPhoneNumber>( "PhoneNumber" ) );

In the parent's DataPortal_Insert, I try to update the child via this call:
DataPortal.UpdateChild( PhoneNumberProperty, dept );

In the child BO, I have the method:
        private void Child_Update( Data.Contacts.Department dept ) {
            Data.Shared.Phone result;

            result = PhoneData.Update( this );

            if ( ReadProperty( TypeProperty ) == "Office" ) {
                dept.Phone = result;
            }
            else {
                dept.Fax = result;
            }
        }

The problem is that on the DataPortal.UpdateChild call it complains that Child_Update is not implemented.  Any ideas?

Thanks
Andy


ajj3085 replied on Wednesday, July 16, 2008

That's the way the project tracker sample is done as well.  It works now.. I forgot the ReadProperty call, and was passing the PropertyInfo instance, not the DepartmentPhoneNumber instance.

Copyright (c) Marimer LLC