using CYQ.Data.Json; using CYQ.Data.SQL; using CYQ.Data.Table; namespace CYQ.Data.Tool { /// /// (表、视图、存储过程)相关信息 /// public class TableInfo { internal TableInfo() { } public TableInfo(string name, string type, string description, DBInfo dbInfo) { _Name = name; _Type = type; _Description = description; _DBInfo = dbInfo; } private string _Name; /// /// (表、视图、存储过程)名称(只读) /// public string Name { get { return _Name; } } private string _Type; /// /// 类型(只读) /// public string Type { get { return _Type; } } private string _Description; /// /// 描述(可写) /// public string Description { get { return _Description; } set { _Description = value; } } private DBInfo _DBInfo; /// /// 数据库信息(只读) /// [JsonIgnore] public DBInfo DBInfo { get { return _DBInfo; } } /// /// 获取指定(表、视图、存储过程)名称的Hash值 /// /// public static string GetHashKey(string name) { name = SqlFormat.NotKeyword(name); return StaticTool.GetHashKey(name.Replace("-", "").Replace("_", "").Replace(" ", "").ToLower()); } /// /// 获取相关的列架构(对表和视图有效) /// public MDataColumn Columns { get { if (Type == "U" || Type == "V") { return TableSchema.GetColumns(Name, DBInfo.ConnString);//里面有缓存,所以无需要存档。 } return null; } } /// /// 刷新表列结构缓存 /// public void Reflesh() { if (Type == "U" || Type == "V") { TableSchema.GetColumns(Name, DBInfo.ConnString, true); } } /// /// 清空缓存【内存和硬盘】 /// internal void RemoveCache() { TableSchema.Remove(Name, DBInfo.ConnString); } } }