MarimerLLC / cslaforum

Discussion forum for CSLA .NET
https://cslanet.com
Other
31 stars 6 forks source link

List item must be marked as a child object #211

Open rnach opened 8 years ago

rnach commented 8 years ago

I have two tables Survey and SurveyQuestion. I'm trying to save multiple questions to one Survey. I'm using @(Html.BeginCollectionItem("SurveyQuestions")){ }. When I click on Save, it says 'List item must be marked as a child object'. Do you know where I need to do that?

When calling the PartialView, I'm marking it as a child but still it does not work. return PartialView("_questionForm", SurveyQuestion.New(true));

public static SurveyQuestion New(Boolean isChild = false) { SurveyQuestion d = DataPortal.Create(); if (isChild) d.MarkAsChild(); return d; }

rockfordlhotka commented 8 years ago

DataPortal.Create creates root objects.

DataPortal.CreateChild creates child objects.

The 'child' methods on DataPortal do not invoke the full data portal (as in those calls will never go across the network to a server - real or logical). See the Using CSLA 4 ebooks for full details.