In a previous post I talked about the new property declaration syntax options in CSLA .NET 3.5. When it comes to child objects, if the shortest form is used then CSLA will pretty much completely take care of all parent-child object interaction so you don't have to do it by hand. This is a tremendous code savings! So declaring a child property like this: private static PropertyInfo<ChildList> ChildListProperty = RegisterProperty<ChildList>(new PropertyInfo<ChildList>("ChildList"); public ChildList ChildList { get { return GetProperty<ChildList>(ChildListProperty); } } allows CSLA to manage the child object. Of course you do need to create the child object somewhere, such as in the DataPortal_XYZ methods: [RunLocal] private void DataPortal_Create() { // initialize other fields here LoadProperty<ChildList>(ChildListProperty, ChildList.NewList()); base.DataPortal_Create(); } private void DataPortal_Fetch(...) { // initialize other fields here LoadProperty<ChildList>(ChildListProperty, ChildList.GetList(this.Id)); } Another option is to use a lazy loading scheme. There are a couple options in how you can use lazy loading. You can avoid the DataPortal_Create() implementation by just creating a new, empty list - and I do this almost all the time now: private static PropertyInfo<ChildList> ChildListProperty = RegisterProperty<ChildList>(new PropertyInfo<ChildList>("ChildList"); public ChildList ChildList { get { if (!FieldManager.FieldExists(ChildListProperty))
Read More...