public string GetColumnComment(string tableName, string columnName) { ColumnInfo colInfo = null; var strKey = (tableName + "@" + columnName).ToLower(); DictColumnInfo.TryGetValue(strKey, out colInfo); return(colInfo?.DeText); }
public string GetColumnComment(string tableName, string columnName) { Db.CheckTabStuct(tableName, columnName); ColumnInfo colInfo = null; var strKey = (tableName + "@" + columnName); DictColumnInfo.TryGetValue(strKey, out colInfo); return(colInfo?.DeText); }
public ColumnInfo this[string tableName, string columnName] { get { ColumnInfo colInfo; var strKey = (tableName + "@" + columnName); DictColumnInfo.TryGetValue(strKey, out colInfo); return(colInfo); } }
public string GetColumnComment(string tableName, string columnName) { ColumnInfo colInfo = null; var strKey = (tableName + "@" + columnName); if (DictColumnInfo.TryGetValue(strKey, out colInfo)) { return(colInfo.DeText); } else { throw new ArgumentException(tableName + "/" + columnName + ",表的列不存在!"); } }
public bool IsExistColumn(string tableName, string columnName) { var strKey = (tableName + "@" + columnName); return(DictColumnInfo.ContainsKey(strKey)); }
public bool Refresh() { this.DictColumnInfo = new IgCaseDictionary <ColumnInfo>(); this.TableInfoDict = new IgCaseDictionary <TableInfo>(); this.TableColumnNameDict = new IgCaseDictionary <List <string> >(); this.TableColumnInfoDict = new IgCaseDictionary <List <ColumnInfo> >(); this.TableColumnComments = new IgCaseDictionary <NameValueCollection>(); string strSql = "SELECT name,'' as desc FROM sqlite_master WHERE type='table' order by name"; string viewSql = "SELECT name,sql FROM sqlite_master WHERE type='view' order by name asc"; string procSql = string.Empty; //Sqlite 没有存储过程功能! try { this.TableComments = Db.GetDataTable(strSql).MapperNameValues("name", "desc"); this.Views = Db.ReadNameValues(viewSql); this.Procs = new NameValueCollection(); if (this.TableComments != null && this.TableComments.Count > 0) { this.TableNames = TableComments.AllKeys.ToList(); var dbConn = Db.CreateConn(); dbConn.Open(); this.Version = dbConn.ServerVersion; foreach (string tableName in TableNames) { TableInfo tabInfo = new TableInfo(); tabInfo.TableName = tableName; tabInfo.TabComment = TableComments[tableName]; List <ColumnInfo> lstColInfo = new List <ColumnInfo>(); List <string> lstColName = new List <string>(); NameValueCollection nvcColDeText = new NameValueCollection(); DataRow[] columns = dbConn.GetSchema("COLUMNS").Select("TABLE_NAME='" + tableName + "'"); foreach (DataRow dr in columns) { ColumnInfo colInfo = new ColumnInfo(); colInfo.Colorder = dr["ORDINAL_POSITION"].ToString().ChangeType <int>(0) + 1; colInfo.ColumnName = dr["COLUMN_NAME"].ToString(); colInfo.Length = dr["CHARACTER_MAXIMUM_LENGTH"].ToString().ChangeType <int?>((int?)null); //colInfo.Preci = dr["NUMERIC_PRECISION"].ToString().ChangeType<int?>(null); colInfo.Scale = dr["NUMERIC_SCALE"].ToString().ChangeType <int?>((int?)null); colInfo.IsPK = dr["PRIMARY_KEY"].ToString().ToLower() == "true" ? true : false; colInfo.CanNull = dr["IS_NULLABLE"].ToString().ToLower() == "true" ? true : false; colInfo.DefaultVal = dr["COLUMN_DEFAULT"].ToString(); colInfo.TypeName = dr["DATA_TYPE"].ToString(); if (colInfo.IsPK && string.Compare(colInfo.TypeName, "integer", true) == 0) { colInfo.IsIdentity = true; } if (colInfo.TypeName == "integer" || colInfo.TypeName == "bigint") { colInfo.Scale = null; } lstColInfo.Add(colInfo); lstColName.Add(colInfo.ColumnName); nvcColDeText.Add(colInfo.ColumnName, string.Empty); var strKey = (tableName + "@" + colInfo.ColumnName).ToLower(); DictColumnInfo.Add(strKey, colInfo); if (colInfo.IsPK) { tabInfo.PriKeyColName = colInfo.ColumnName; if (colInfo.IsIdentity) { tabInfo.PriKeyType = PrimaryKeyType.AUTO; } else { tabInfo.PriKeyType = PrimaryKeyType.SET; } } Global.Dict_Sqlite_DbType.TryGetValue(colInfo.TypeName, out DbType type); colInfo.DbType = type; } tabInfo.Colnumns = lstColInfo; this.TableInfoDict.Add(tableName, tabInfo); this.TableColumnNameDict.Add(tableName, lstColName); this.TableColumnInfoDict.Add(tableName, lstColInfo); this.TableColumnComments.Add(tableName, nvcColDeText); } dbConn.Close(); } } catch (Exception ex) { LogUtils.LogError("DB", Developer.SysDefault, ex); return(false); } return(this.TableComments.Count == this.TableInfoDict.Count); }