ZhiYeJianKang_PeiXun/cyqdata-master/Tool/DBEntity/TableInfo.cs
2025-02-20 15:41:53 +08:00

76 lines
2.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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