Files
FreeSql/FreeSql/DatabaseModel/DBTableInfo.cs
T
28810 78fded3f8e - 增加 IndexAttribute 特性,自动迁移索引,以及对应的 FluentApi 方法;
- 移除 ColumnAttribute.Unique 属性设置,改为 IndexAttribute 特性设置唯一键;
2019-10-03 04:31:04 +08:00

63 lines
2.1 KiB
C#

using System.Collections.Generic;
using System.Linq;
namespace FreeSql.DatabaseModel
{
public class DbTableInfo
{
/// <summary>
/// 唯一标识
/// </summary>
public string Id { get; set; }
/// <summary>
/// SqlServer下是Owner、PostgreSQL下是Schema、MySql下是数据库名
/// </summary>
public string Schema { get; set; }
/// <summary>
/// 表名
/// </summary>
public string Name { get; set; }
/// <summary>
/// 表备注,SqlServer下是扩展属性 MS_Description
/// </summary>
public string Comment { get; set; }
/// <summary>
/// 表/视图
/// </summary>
public DbTableType Type { get; set; }
/// <summary>
/// 列
/// </summary>
public List<DbColumnInfo> Columns { get; set; } = new List<DbColumnInfo>();
/// <summary>
/// 自增列
/// </summary>
public List<DbColumnInfo> Identitys { get; set; } = new List<DbColumnInfo>();
/// <summary>
/// 主键/组合
/// </summary>
public List<DbColumnInfo> Primarys { get; set; } = new List<DbColumnInfo>();
/// <summary>
/// 唯一键/组合
/// </summary>
public Dictionary<string, DbIndexInfo> UniquesDict { get; set; } = new Dictionary<string, DbIndexInfo>();
/// <summary>
/// 索引/组合
/// </summary>
public Dictionary<string, DbIndexInfo> IndexesDict { get; set; } = new Dictionary<string, DbIndexInfo>();
/// <summary>
/// 外键
/// </summary>
public Dictionary<string, DbForeignInfo> ForeignsDict { get; set; } = new Dictionary<string, DbForeignInfo>();
public List<DbIndexInfo> Uniques => UniquesDict.Values.ToList();
public List<DbIndexInfo> Indexes => IndexesDict.Values.ToList();
public List<DbForeignInfo> Foreigns => ForeignsDict.Values.ToList();
}
public enum DbTableType
{
TABLE, VIEW, StoreProcedure
}
}