Exemple #1
0
 public DbMapInfo(string dbName, string netName, DataColumnAttribute attrColumn, IgnoreColumnAttribute attrIgnore, PropertyInfo prop)
 {
     this.DbName       = dbName;
     this.NetName      = netName;
     this.AttrColumn   = attrColumn;
     this.PropertyInfo = prop;
     this.AttrIgnore   = attrIgnore;
 }
        public static TypeDescription GetTypeDiscription(Type type)
        {
            TypeDescription description = s_typeInfoDict[type.FullName] as TypeDescription;

            if (description == null)
            {
                PropertyInfo[] properties           = type.GetProperties(s_flag);
                int            length               = properties.Length;
                Dictionary <string, DbMapInfo> dict = new Dictionary <string, DbMapInfo>(length, StringComparer.OrdinalIgnoreCase);

                foreach (PropertyInfo prop in properties)
                {
                    DbMapInfo info = null;

                    DataColumnAttribute   attrColumn = prop.GetMyAttribute <DataColumnAttribute>();
                    IgnoreColumnAttribute attrIgnore = prop.GetMyAttribute <IgnoreColumnAttribute>();

                    if (attrColumn != null)
                    {
                        info = new DbMapInfo(string.IsNullOrEmpty(attrColumn.Alias) ? prop.Name : attrColumn.Alias, prop.Name, attrColumn, attrIgnore, prop);
                    }
                    else
                    {
                        info = new DbMapInfo(prop.Name, prop.Name, null, attrIgnore, prop);
                    }

                    dict[info.DbName] = info;
                }

                description = new TypeDescription {
                    MemberDict = dict
                };

                // 添加到缓存字典
                s_typeInfoDict[type.FullName] = description;
            }

            return(description);
        }