using System; using System.Collections.Generic; using System.Text; namespace IOTContainer.SQLite { /// /// 字段信息 /// public class SQLiteColumn { #region 构造函数 public SQLiteColumn() { this.ColumnName = string.Empty; this.PrimaryKey = false; this.ColumnType = SQLiteColumnType.Text; this.AutoIncrement = false; this.NotNull = false; this.DefaultValue = string.Empty; } public SQLiteColumn(string colName) : this() { this.ColumnName = colName; } public SQLiteColumn(string colName, SQLiteColumnType colDataType) : this(colName) { this.ColumnType = colDataType; } public SQLiteColumn(string colName, bool autoIncrement) : this(colName) { if (autoIncrement) { this.PrimaryKey = true; this.ColumnType = SQLiteColumnType.Integer; this.AutoIncrement = true; } else { this.PrimaryKey = false; this.ColumnType = SQLiteColumnType.Text; this.AutoIncrement = false; } } public SQLiteColumn(string colName, SQLiteColumnType colDataType, bool primaryKey, bool autoIncrement, bool notNull, string defaultValue) : this(colName) { if (autoIncrement) { this.PrimaryKey = true; this.ColumnType = SQLiteColumnType.Integer; this.AutoIncrement = true; } else { this.PrimaryKey = primaryKey; this.ColumnType = colDataType; this.AutoIncrement = false; this.NotNull = notNull; this.DefaultValue = defaultValue; } } #endregion #region 字段属性 /// /// 字段名 /// public string ColumnName { get; set; } /// /// 是否有主键 /// public bool PrimaryKey { get; set; } /// /// 类型 /// public SQLiteColumnType ColumnType { get; set; } /// /// 自增 /// public bool AutoIncrement { get; set; } /// /// 不为空 /// public bool NotNull { get; set; } /// /// 默认值 /// public string DefaultValue { get; set; } #endregion } }