I'm having a small problem with a list of objects, the list is always coming back marked as a child(I checked in the immediate window during debugging). I have the following code:
public static Scores GetScoresBySomeID(int SomeID)
{
return DataPortal.Fetch< Scores >( SomeID );
}
private DataPortal_Fetch(int SomeID)
{
bool cancel = false;
OnFetching(SurveyID, ref cancel); // empty partial method, part of code gen
if (cancel) return;
Fetch(SomeID); // this calls a private method, gets a connection to the db and populates the child
// objects in this list
OnFetched();// empty partial method, part of code gen
}
private void Fetch(int SurveyID)
{
RaiseListChangedEvents = false;
ScoresData data = ScoresData.NewScoresData(); // POCO data access object
List< ScoresData > results = data.GetScoresBySomeID(SomeID);
foreach ( ScoresData info in results)
{
Add(new ScoreLevel(info)); // creates a csla child biz object and add to list
}
RaiseListChangedEvents = true;
}
I also have child factory methods(and child_xyz methods)
I've set breakpoints and stepped through the code and it's stepping through the DataPortal_xyz, but IsChild is still true. I'm not sure what I did wrong, or how to override CSLA and set this list as a Parent.
To add another snippet, in the controller:
int myID = SomeMethodToGetID();
Scores myScores = Scores.GetScoresBySomeID(myID);
as far as I know, if myScores were a child it shouldn't be able to get itself(if it were a child it would need to belong to a parent, and the parent would take the child object(s) through the dataportal). So I don't quite understand how it can be child and yet go through the dataportal on it's own.
Did you check the list's default constructor? Does Scores() accidentially set the child flag?
Good call, I didn't think to look(and it was code generated(not sure why the constructor is setting that), but that's where the problem is.
Thanks for the tip!
Copyright (c) Marimer LLC