Quantcast
Viewing all articles
Browse latest Browse all 764

3.6 to 4.5: Has DataPortal.UpdateChild changed?

 

Hi 

I've been working through migrating a small 3.6.3 project to 4.5.40. I've got readonly objects returning, and CRUD working on editable roots, but I'm having problems with their child editable lists.

The class is declared as:

public partial class CrewMemberER : MyBusinessBase<CrewMemberER>

Where MyBusinessBase inherits from Jonny's Csla.Validation.BusinessBase<T>.

 

The update method is then:

       #region Data Access - Update

              [Transactional(TransactionalTypes.TransactionScope)]

              protected override void DataPortal_Update()

              {

                     bool cancel = false;

                     OnUpdating(ref cancel);

                     if (cancel) return;

                     using (var mgr = ContextManager<Core.Data.Linq.BASE_PROJECTDataContext>

                                         .GetManager(Core.Data.Linq.Database.BASE_PROJECT))

                     {

                           var data = new Core.Data.Linq.CREW_MEMBER()

                           {

                                  CrewMemberId = ReadProperty(CrewMemberIdProperty)

                           };

                           data.LastChanged = _lastChanged;

                           OnMemberReading(data);

                           if (IsSelfDirty)

                           {

                                  data.TitleId = ReadProperty(TitleIdProperty);

                                  data.FirstName = ReadProperty(FirstNameProperty);

                                  data.LastName = ReadProperty(LastNameProperty);

                                  data.Notes = ReadProperty(NotesProperty);

                                  data.DateEntered = ReadProperty(DateEnteredProperty);

                                  data.EnteredById = ReadProperty(EnteredByIdProperty);

                                  data.LastChangedById = Security.ApplicationPrincipal.CurrentApplicationIdentity.UserContactId.Value;

                                  data.IsCurrentOption = ReadProperty(IsCurrentOptionProperty);

                                  data.LegacyId = ReadProperty(LegacyIdProperty);

                                  mgr.DataContext.CREW_MEMBERs.Attach(data, true);

                           }

                           //Update Child object(s)

                           DataPortal.UpdateChild(ReadProperty(CrewMemberVaccinationECLProperty), this);

                           DataPortal.UpdateChild(ReadProperty(CrewMemberHotelECLProperty), this);

                           OnMemberRead();

                           mgr.DataContext.SubmitChanges();

                           if (IsSelfDirty)

                           {

                                  _lastChanged = data.LastChanged.ToArray();

                           }

                     }//using

                     OnUpdated();

 

 

The actual exception is:

 

System.InvalidCastException occurred

  HResult=-2147467262

  Message=Unable to cast object of type 'Core.Business.Library.Crew.CrewMemberER' to type'Core.Business.Library.Crew.CrewMemberVaccinationECL'.

  Source=Anonymously Hosted DynamicMethods Assembly

  StackTrace:

      at lambda_method(Closure , Object , Object[] )

      at Csla.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Boolean hasParameters, Object[] parameters) in c:\Program Files (x86)\Marimer LLC\CSLA .NET\4.5.40\Source\Csla\Reflection\MethodCaller.cs:line 524

  InnerException: 

 

Which seems to suggest I shouldn't be passing 'this' to the UpdateChild method?  These update scripts are based on the linq2sql based templates so to be honest I don't completely understand why the parent is being passed in in the first place.  

 

Is there an obvious answer to this?

 

 

 


Viewing all articles
Browse latest Browse all 764

Trending Articles