Ejemplo n.º 1
0
        /// <summary>
        /// 创建实体对象的表
        /// </summary>
        /// <param name="root"></param>
        /// <param name="master"></param>
        /// <param name="memberField"></param>
        /// <param name="isMultiple"></param>
        /// <returns></returns>
        private static DataTable CreateEntityObjectTable(DataTable root, DataTable master, IDataField memberField, Type objectType)
        {
            //注意,在内聚模型中,只要是实体对象,那么它就是相对于内聚根的实体对象,而不是所在对象的实体对象
            //因此,所有的实体对象,外键存放的都是内聚根的编号
            var fields = new List <IDataField>();

            fields.AddRange(DataModel.GetObjectFields(objectType, master.IsSnapshot)); //增加对象定义的领域属性
            if (!objectType.IsDerived())
            {
                //派生类不必有引用次数
                fields.Add(GeneratedField.CreateAssociatedCount(objectType));//追加被引用次数
            }

            return(DataTable.Create(root,
                                    master,
                                    objectType,
                                    master.IsSnapshot,//根据从表,判断是否为快照
                                    DataTableType.EntityObject, fields, memberField));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 创建值对象的表
        /// </summary>
        /// <param name="root"></param>
        /// <param name="master"></param>
        /// <param name="memberField"></param>
        /// <param name="isMultiple"></param>
        /// <returns></returns>
        private static DataTable CreateValueObjectTable(DataTable root, DataTable master, IDataField memberField, Type objectType)
        {
            var fields = new List <IDataField>();

            fields.Add(GeneratedField.CreateValueObjectPrimaryKey(objectType));        //追加主键
            fields.AddRange(DataModel.GetObjectFields(objectType, master.IsSnapshot)); //增加对象定义的领域属性

            if (!objectType.IsDerived())
            {
                //派生类不必追加引用次数
                fields.Add(GeneratedField.CreateAssociatedCount(objectType));//追加被引用次数
            }

            return(DataTable.Create(root,
                                    master,
                                    objectType,
                                    master.IsSnapshot,//根据主表,判断是否为快照
                                    DataTableType.ValueObject,
                                    fields,
                                    memberField));
        }