Child record ApplyEdit fails for split partial class.Child record ApplyEdit fails for split partial class.
Old forum URL: forums.lhotka.net/forums/t/1959.aspx
Tommybouy posted on Tuesday, December 12, 2006
We use the CodeSmith generator and the VB templates and although everything appears correct, when we try to update a child record we get the "Can not directly save a child object" error. It seems the
Protected
Overrides Sub AcceptChangesComplete()
If Parent IsNot Nothing Then
Parent.ApplyEditChild(
Me)
End If
MyBase.AcceptChangesComplete()
End Sub
causes the error because Parent is nothing even though Setparent is being called when objects are being created. I'm not sure if this is a split partial issue or not. Any ideas?
Thanks
Tom
xal replied on Tuesday, December 12, 2006
Definitely not a partial class issue.
You're sure you have a parent collection defined? What's the type of the parent collection?
This error is typically raised when calling Save on a child item. Is it possible that you're using the new EditableRootListBase as your collection? Are you calling save directly on the child?
Andrés
Tommybouy replied on Wednesday, December 13, 2006
I am using BusinessListBase as my parent collection and it does call MarkAsChild in the New methods. From Chapter 9 Rocky creates a clone of his object then calls applyedit, then save on that clone. Prior to the cloning process the Parent property contains a value, after the clone it does not. Either the saving process should be different for a child, I am doing it wrong, or the cloning process is flawed. Am I at fault?Copyright (c) Marimer LLC