- 增加 IndexAttribute 特性,自动迁移索引,以及对应的 FluentApi 方法;

- 移除 ColumnAttribute.Unique 属性设置,改为 IndexAttribute 特性设置唯一键;
This commit is contained in:
28810
2019-10-03 04:31:04 +08:00
parent cb18b74830
commit 78fded3f8e
43 changed files with 1010 additions and 607 deletions

View File

@ -40,18 +40,18 @@ namespace FreeSql.DatabaseModel
/// <summary>
/// 唯一键/组合
/// </summary>
public Dictionary<string, List<DbColumnInfo>> UniquesDict { get; set; } = new Dictionary<string, List<DbColumnInfo>>();
public Dictionary<string, DbIndexInfo> UniquesDict { get; set; } = new Dictionary<string, DbIndexInfo>();
/// <summary>
/// 索引/组合
/// </summary>
public Dictionary<string, List<DbColumnInfo>> IndexesDict { get; set; } = new Dictionary<string, List<DbColumnInfo>>();
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<List<DbColumnInfo>> Uniques => UniquesDict.Values.ToList();
public List<List<DbColumnInfo>> Indexes => IndexesDict.Values.ToList();
public List<DbIndexInfo> Uniques => UniquesDict.Values.ToList();
public List<DbIndexInfo> Indexes => IndexesDict.Values.ToList();
public List<DbForeignInfo> Foreigns => ForeignsDict.Values.ToList();
}

View File

@ -0,0 +1,21 @@
using FreeSql.DataAnnotations;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq.Expressions;
namespace FreeSql.DatabaseModel
{
public class DbIndexInfo
{
public string Name { get; set; }
public List<DbIndexColumnInfo> Columns { get; } = new List<DbIndexColumnInfo>();
public bool IsUnique { get; set; }
}
public class DbIndexColumnInfo
{
public DbColumnInfo Column { get; set; }
public bool IsDesc { get; set; }
}
}