コード例 #1
0
 public PropertyDataInfoHelper(PropertyDataInfo item, IDataViewMetaData viewMetaData)
 {
     _dataConig = item;
     _viewMetaData = viewMetaData;
 }
コード例 #2
0
 public PropertyDataInfoHelper(PropertyDataInfo item, IDataViewMetaData viewMetaData)
 {
     _dataConig    = item;
     _viewMetaData = viewMetaData;
 }
コード例 #3
0
        public void Buid <T>() where T : class
        {
            DataConfigureAttribute custAttribute = DataConfigureAttribute.GetAttribute <T>();

            TargeType = typeof(T);
            System.Reflection.PropertyInfo[] propertys = TargeType.GetProperties();
            if (custAttribute != null)
            {
                if (!DataBase.IsExistTable(custAttribute.MetaData.Table))
                {
                    DataBase.CreateTable <T>();
                }
                else
                {
                    foreach (var item in propertys)
                    {
                        TypeCode code = Type.GetTypeCode(item.PropertyType.IsGenericType ? item.PropertyType.GetGenericArguments()[0] : item.PropertyType);

                        if (custAttribute.MetaData.PropertyDataConfig.ContainsKey(item.Name))
                        {
                            PropertyDataInfo config = custAttribute.MetaData.PropertyDataConfig[item.Name];

                            if (!config.Ignore && !config.IsRelation)
                            {
                                string columnName = string.IsNullOrEmpty(config.ColumnName)
                                    ? config.PropertyName
                                    : config.ColumnName;
                                if (!DataBase.IsExistColumn(custAttribute.MetaData.Table, columnName))
                                {
                                    DataBase.AddColumn(custAttribute.MetaData.Table, columnName, Common.ConvertToDbType(code),
                                                       config.StringLength);
                                }
                                else
                                {
                                    DataBase.AlterColumn(custAttribute.MetaData.Table, columnName,
                                                         Common.ConvertToDbType(code),
                                                         config.StringLength);
                                }
                            }
                        }
                        else
                        {
                            if (!DataBase.IsExistColumn(custAttribute.MetaData.Table, item.Name))
                            {
                                DataBase.AddColumn(custAttribute.MetaData.Table, item.Name, Common.ConvertToDbType(code));
                            }
                            else
                            {
                                DataBase.AlterColumn(custAttribute.MetaData.Table, item.Name, Common.ConvertToDbType(code));
                            }
                        }
                    }
                }
            }
            else
            {
                if (!DataBase.IsExistTable(TargeType.Name))
                {
                    DataBase.CreateTable <T>();
                }
                else
                {
                    foreach (var item in propertys)
                    {
                        TypeCode code = Type.GetTypeCode(item.PropertyType.IsGenericType ? item.PropertyType.GetGenericArguments()[0] : item.PropertyType);
                        if (!DataBase.IsExistColumn(TargeType.Name, item.Name))
                        {
                            DataBase.AddColumn(TargeType.Name, item.Name, Common.ConvertToDbType(code));
                        }
                        else
                        {
                            DataBase.AlterColumn(TargeType.Name, item.Name, Common.ConvertToDbType(code));
                        }
                    }
                }
            }
        }