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
protected override void DataPortal_Update()
bool cancel = false;
if (cancel) return;
using (var mgr = ContextManager<Core.Data.Linq.BASE_PROJECTDataContext>
var data = new Core.Data.Linq.CREW_MEMBER()
CrewMemberId = ReadProperty(CrewMemberIdProperty)
data.LastChanged = _lastChanged;
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);
//Update Child object(s)
_lastChanged = data.LastChanged.ToArray();
The actual exception is:
Message=Unable to cast object of type 'Core.Business.Library.Crew.CrewMemberER' to type 'Core.Business.Library.Crew.CrewMemberVaccinationECL'.
Source=Anonymously Hosted DynamicMethods Assembly
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
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?
Well, I solved it by taking the second 'this' parameter out and that seemed to get it working correctly. Not sure why it was there in the first place.
DataPortal.UpdateChild code hasn't changed but MethodCaller has seen some updates in how it determines which method to call based on the parameters supplied.
So I believe this is the difference.
Ahhhh... that makes sense. Right, I'll have a read up on that and see if that has ramifications for code elsewhere too. Thanks for your help Jonny.
Copyright (c) Marimer LLC