示例#1
0
        /// <summary>
        ///		Convierte el tipo
        /// </summary>
        private DataSourceColumnModel.FieldType Convert(FieldDbModel.Fieldtype type)
        {
            switch (type)
            {
            case FieldDbModel.Fieldtype.Binary:
                return(DataSourceColumnModel.FieldType.Binary);

            case FieldDbModel.Fieldtype.Boolean:
                return(DataSourceColumnModel.FieldType.Boolean);

            case FieldDbModel.Fieldtype.Date:
                return(DataSourceColumnModel.FieldType.Date);

            case FieldDbModel.Fieldtype.Decimal:
                return(DataSourceColumnModel.FieldType.Decimal);

            case FieldDbModel.Fieldtype.Integer:
                return(DataSourceColumnModel.FieldType.Integer);

            case FieldDbModel.Fieldtype.String:
                return(DataSourceColumnModel.FieldType.String);

            default:
                return(DataSourceColumnModel.FieldType.Unknown);
            }
        }
示例#2
0
 /// <summary>
 ///		Añade una tabla / vista a la colección del esquema
 /// </summary>
 public void Add(bool isTable, string schema, string tableName, string fieldName,
                 FieldDbModel.Fieldtype fieldType, string fieldDbType, int fieldLength, bool isPrimaryKey, bool isRequired)
 {
     // Normaliza los datos
     schema = schema ?? "";
     // Añade el elemento
     if (!string.IsNullOrWhiteSpace(tableName) && !string.IsNullOrWhiteSpace(fieldName))
     {
         if (isTable)
         {
             Add(Tables, schema, tableName, fieldName, fieldType, fieldDbType, fieldLength, isPrimaryKey, isRequired);
         }
         else
         {
             Add(Views, schema, tableName, fieldName, fieldType, fieldDbType, fieldLength, isPrimaryKey, isRequired);
         }
     }
 }
        /// <summary>
        ///		Añade un campo a la tabla
        /// </summary>
        public void AddField(string name, FieldDbModel.Fieldtype type, string dbType, int length, bool isPrimaryKey, bool isRequired)
        {
            FieldDbModel field = Fields.FirstOrDefault(item => item.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase));

            // Si no existía el campo, se crea
            if (field == null)
            {
                field = new FieldDbModel {
                    Name = name
                };
                Fields.Add(field);
            }
            // Asigna las propiedades
            field.Type       = type;
            field.DbType     = dbType;
            field.Length     = length;
            field.IsKey      = isPrimaryKey;
            field.IsRequired = isRequired;
        }
示例#4
0
        /// <summary>
        ///		Convierte el tipo de campo
        /// </summary>
        private ConnectionTableFieldModel.Fieldtype Convert(FieldDbModel.Fieldtype type)
        {
            switch (type)
            {
            case FieldDbModel.Fieldtype.String:
                return(ConnectionTableFieldModel.Fieldtype.String);

            case FieldDbModel.Fieldtype.Date:
                return(ConnectionTableFieldModel.Fieldtype.Date);

            case FieldDbModel.Fieldtype.Integer:
                return(ConnectionTableFieldModel.Fieldtype.Integer);

            case FieldDbModel.Fieldtype.Decimal:
                return(ConnectionTableFieldModel.Fieldtype.Decimal);

            case FieldDbModel.Fieldtype.Boolean:
                return(ConnectionTableFieldModel.Fieldtype.Boolean);

            default:
                return(ConnectionTableFieldModel.Fieldtype.Unknown);
            }
        }
示例#5
0
        /// <summary>
        ///		Añade la vista a la colección y un campo a la vista
        /// </summary>
        private void Add(List <ViewDbModel> views, string schema, string tableName, string fieldName, FieldDbModel.Fieldtype fieldType,
                         string fieldDbType, int fieldLength, bool isPrimaryKey, bool isRequired)
        {
            ViewDbModel view = Search(views, schema, tableName);

            // Añade un campo a la tabla
            view.AddField(fieldName, fieldType, fieldDbType, fieldLength, isPrimaryKey, isRequired);
        }
示例#6
0
        /// <summary>
        ///		Añade la tabla a la colección y un campo a la tabla
        /// </summary>
        private void Add(List <TableDbModel> tables, string schema, string tableName, string fieldName, FieldDbModel.Fieldtype fieldType,
                         string fieldDbType, int fieldLength, bool isPrimaryKey, bool isRequired)
        {
            TableDbModel table = Search(tables, schema, tableName);

            // Añade un campo a la tabla
            table.AddField(fieldName, fieldType, fieldDbType, fieldLength, isPrimaryKey, isRequired);
        }