Problem saving child object

Problem saving child object

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


jjloubser@symbioses.co.za posted on Wednesday, July 14, 2010

 

I have the problem with the update:

I am working in CSLA.net 4 <4.0.0>, Using a DataGrid with a BusinessListBase and  BusinessBase. My fetch work nice.

To update a line in the Grid my CanSave binding works on my apply button. I use this:

 <Button x:Name="ButtonApplyTop"
                            Width="75" Content="Apply"
                            IsEnabled="{Binding CanSave, Mode=OneWay}"/>

                    <my1:TriggerAction Height="0" x:Name="ButtonApplyTopTrigger" Width="0"
                               TargetControl="{Binding ElementName=ButtonApplyTop}"
                               TriggerEvent="Click" MethodName="Save"
                               />

 

When I click Apply it execute the save method, i know because i ovveride it, but do not reach my Child_Update() in the BusinessBase:

 private void Child_Update()
        {

        }

Do not even reach this in:

BusinessListBase:

 

 [Transactional(TransactionalTypes.TransactionScope)]
        protected override void DataPortal_Update()
        {
          
            using (var ctx = ConnectionManager<SqlConnection>.GetManager("StaffSenseDb"))
            {
                base.Child_Update(ctx);
                //FieldManager.UpdateChildren(this);
              
            }
        }

 

I also try this in the child object not working:

   #if !SILVERLIGHT

[Transactional(TransactionalTypes.TransactionScope)]
        protected override void DataPortal_Update()
        {
            base.DataPortal_Update();

            using (var ctx = ConnectionManager<SqlConnection>.GetManager("xxxx"))
            {

            }

     }

 

   #endif

What is wrong? Please help.

RockfordLhotka replied on Wednesday, July 14, 2010

What does your root object's DataPortal_Insert and DataPortal_Update look like? Are you calling the appropriate child update methods?

jjloubser@symbioses.co.za replied on Friday, July 16, 2010

sorry for the late reply, we wanted to transfer our  code to the latest csla 4 dll's. we had to create a new project for it to work, becuase the bxf dll's crashed with the old csla 4 dll's and we could not clean the dll's out of the compiler, so we created a new project and put in the new csla 4 dll's and it work.

we still get the problem, the fetch works, we do not need insert only update of lines in grid.

For the update:

 

<BusinessListBase:>

 private void DataPortal_Fetch(Business.RowCall.RowCallDetailsCriteria criteria)
        {

            using (var ctx = ConnectionManager<SqlConnection>.GetManager("XXX"))
            {
                using (var cm = ctx.Connection.CreateCommand())
                {

...

                }

          }

 

  #if !SILVERLIGHT

        [Transactional(TransactionalTypes.TransactionScope)]
        protected override void DataPortal_Update()                           // this is never been reach
        {
          
            using (var ctx = ConnectionManager<SqlConnection>.GetManager("StaffSenseDb"))
            {
                base.Child_Update(ctx);
                //FieldManager.UpdateChildren(this);
              
            }
        }

       #endif

on the BusinessListBase client it gives an error 'update to server fails'' at:

  public override void Child_Update(params object[] parameters)
        {
            base.Child_Update(parameters);
        }

 

 

<BusinessBase>


 private void Child_Fetch(SafeDataReader dr, Business.RowCall.RowCallDetailsCriteria criteria)
        {

...

//woring

        }

 

private void Child_Update() //not working
        {

// also tried private void Child_Update(params object[] parameters)

 

        }

 

  #if !SILVERLIGHT

        [Transactional(TransactionalTypes.TransactionScope)] //not working
        protected override void DataPortal_Update()
        {
            base.DataPortal_Update();

            using (var ctx = ConnectionManager<SqlConnection>.GetManager("StaffSenseDb"))
            {

...

           }

 

}

JJLoubser replied on Wednesday, August 18, 2010

VMMV Search:

public void Search()
   {

       Presenter.ShowStatus(new Status { IsBusy = true, Text = "Searching row calls..." });
       BeginRefresh("Search");

 

}

 

Client Side:

 public static void Search(EventHandler<DataPortalResult<RowCallSummaryRORL>> callback)
        {
            var dp = new DataPortal<RowCallSummaryRORL>();
            dp.FetchCompleted += callback;
            dp.BeginFetch(rowCallSummaryDateCriteria_);
        }

Server side:

 

private void Child_Fetch(SafeDataReader dr, Business.RowCall.RowCallDetailsCriteria criteria)
        {

 

...

       }

 

Apply:

 

server side:

 private void Child_Update()
        {

...

       }

 

we just had to play around with the ViewModel verbs, Server Side names and Criteria Objects content

Copyright (c) Marimer LLC