예제 #1
0
파일: Table.cs 프로젝트: dalinhuang/myxx
        /// <summary>
        /// ����������������Ϣ�͹�������Ϣ
        /// </summary>
        private PropertyInfo[] BuildPropertyColumns()
        {
            PropertyInfo[] props = TargetType.GetProperties(FLAGS);

            foreach (PropertyInfo prop in props)
            {
                //���һ����������ݵ�ֵ����ӳ������
                object[] colAttrs = prop.GetCustomAttributes(typeof(ColumnMappingAttribute), true);
                if (colAttrs.Length == 1)
                {
                    ColumnMappingAttribute cma = colAttrs[0] as ColumnMappingAttribute;
                    Column column = new PropertyColumn(cma, prop);
                    column.TableName = this.name;

                    if (column.IsPrimaryKey)
                        this.primaryColumns.Add(column);

                    this.columns.Add(column);
                }
            }

            return props;
        }
예제 #2
0
        /// <summary>
        /// ��������Ϣ�͹�������Ϣ
        /// </summary>
        private void BuildPropertyColumns()
        {
            PropertyInfo[] props = TargetType.GetProperties(FLAGS);
            foreach (PropertyInfo prop in props)
            {
                object[] colAttrs = prop.GetCustomAttributes(typeof(ColumnMappingAttribute), true);
                if (colAttrs.Length == 1)
                {
                    ColumnMappingAttribute cma = colAttrs[0] as ColumnMappingAttribute;
                    Column column = new PropertyColumn(cma, prop);

                    if (column.IsPrimaryKey)
                    {
                        this.primaryColumns.Add(column);
                    }

                    this.columns.Add(column);
                }

                object[] relationReflectAttrs = prop.GetCustomAttributes(typeof(RelationReflectMappingAttribute), true);
                object[] relationFieldAttrs = prop.GetCustomAttributes(typeof(RelationFieldMappingAttribute), true);
                if (relationReflectAttrs.Length == 1 && relationFieldAttrs.Length == 1)
                {
                    RelationReflectMappingAttribute rrMapping = relationReflectAttrs[0] as RelationReflectMappingAttribute;
                    RelationFieldMappingAttribute rfMapping = relationFieldAttrs[0] as RelationFieldMappingAttribute;

                    RelationDef def = null;
                    for (int j = 0; j < relationDefs.Count; j++)
                    {
                        def = (RelationDef)relationDefs[j];
                        if ((def.TabelAlias == rrMapping.TableAlias) && (def.SourceTableAlias == rrMapping.SourceTableAlias))
                        {
                            break;
                        }
                        def = null;
                    }

                    if (def == null)
                    {
                        def = new RelationDef(rrMapping.TableName, rrMapping.SourceTableName);
                        def.TabelAlias = rrMapping.TableAlias;
                        def.SourceTableAlias = rrMapping.SourceTableAlias;
                        def.JoinType = TypeHelper.TableJOINTypeToString(rrMapping.JoinType);
                        relationDefs.Add(def);
                    }
                    RelationDetail detail = new RelationDetail(rfMapping.FieldName, rfMapping.SourceFieldName);
                    detail.Compare = rfMapping.Compare;
                    def.RelationDetails.Add(detail);
                }
            }
        }