using CYQ.Data.SQL;
using CYQ.Data.Table;
using System;
using System.Collections.Generic;
using System.Text;
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;
///
/// 数据库信息(只读)
///
public DBInfo DBInfo { get { return _DBInfo; } }
///
/// 获取指定(表、视图、存储过程)名称的Hash值
///
///
public static int GetHashCode(string name)
{
if (string.IsNullOrEmpty(name)) {
return "".GetHashCode();
}
return Math.Abs(name.Replace("-", "").Replace("_", "").Replace(" ", "").ToLower().GetHashCode());
}
///
/// 获取相关的列架构(对表和视图有效)
///
public MDataColumn Columns
{
get
{
if (Type == "U" || Type == "V")
{
return TableSchema.GetColumns(Name, DBInfo.ConnString);
}
return null;
}
}
}
}