internal DbFieldSchema(string source, string fieldDelimiter)
        {
            if (source.IsNullOrWhiteSpace())
            {
                throw new ArgumentNullException(nameof(source));
            }
            if (null == fieldDelimiter || fieldDelimiter.Length < 1)
            {
                throw new ArgumentNullException(nameof(fieldDelimiter));
            }

            _name               = source.GetDelimitedField(0, fieldDelimiter);
            _dataType           = source.GetDelimitedField(1, fieldDelimiter).GetEnumOrDefault(DbDataType.Char);
            _length             = source.GetDelimitedField(2, fieldDelimiter).GetInt32OrDefault(255);
            _notNull            = source.GetDelimitedField(3, fieldDelimiter).GetBooleanOrDefault(true);
            _autoincrement      = source.GetDelimitedField(4, fieldDelimiter).GetBooleanOrDefault(false);
            _unsigned           = source.GetDelimitedField(5, fieldDelimiter).GetBooleanOrDefault(true);
            _enumValues         = source.GetDelimitedField(6, fieldDelimiter);
            _description        = source.GetDelimitedField(7, fieldDelimiter);
            _indexType          = source.GetDelimitedField(8, fieldDelimiter).GetEnumOrDefault(DbIndexType.None);
            _indexName          = source.GetDelimitedField(9, fieldDelimiter);
            _onUpdateForeignKey = source.GetDelimitedField(10, fieldDelimiter).GetEnumOrDefault(DbForeignKeyActionType.Cascade);
            _onDeleteForeignKey = source.GetDelimitedField(11, fieldDelimiter).GetEnumOrDefault(DbForeignKeyActionType.Restrict);
        }
Exemple #2
0
 private static bool IsPrimaryKey(this DbIndexType indexType)
 {
     return(indexType == DbIndexType.ForeignPrimary || indexType == DbIndexType.Primary);
 }