CSLA如何使用子父关系创建信息类

时间:2015-06-29 11:06:18

标签: c# csla

我是CSLA的新手,所以我想弄清楚如何解决以下问题。我想写下4个信息类,如下图所示。 enter image description here

它们都是信息类,DayRecordInfoCollection是DayRecordInfo对象的集合,而DayRecord可以有更多活动,因此它是ActivityRecordCollectionInfo的父级,它是ActivityRecordInfo的集合。 此外,DayRecordInfo有3个属性,Id,StartTime,EndTime和ActivityRecordInfo有4个属性,Id,IdDayRecord,StartTime,EndTime。 enter image description here

到目前为止,我已经创建了4个基本的结构化Info classe

- public class DayRecordInfo : ReadOnlyBase<DayRecordInfo>

- public class DayRecordInfoCollection : ReadOnlyBindingListBase<DayRecordInfoCollection,DayRecordInfo>

- public class ActivityRecordInfoCollection : ReadOnlyBindingListBase<ActivityRecordInfoCollection,ActivityRecordInfo>

- public class ActivityRecordInfo : ReadOnlyBase<ActivityRecordInfo>

现在,我正在试图找出如何将它们与FieldManager相关联。 我想在DayRecordInfo中创建属性,就像这样

public static readonly PropertyInfo<ActivityRecordInfoCollection> ActivitiesProperty = RegisterProperty<ActivityRecordInfoCollection>(c => c.Activities);
    public ActivityRecordInfoCollection Activities
    {
        get 
        {
            if (!(FieldManager.FieldExists(ActivitiesProperty)))
            {
                LoadProperty(ActivitiesProperty, DataPortal.CreateChild<ActivityRecordInfoCollection>());
            }
            return GetProperty(ActivitiesProperty);
        }
        private set { LoadProperty(ActivitiesProperty, value); }
    }

有什么想法吗? 提前致谢

1 个答案:

答案 0 :(得分:1)

\ Support \ Snippets文件夹中有代码片段,演示如何定义同步或异步加载的子属性。

https://github.com/MarimerLLC/csla/tree/master/Support/Snippets