mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 04:18:16 +08:00
- 增加 IndexAttribute 特性,自动迁移索引,以及对应的 FluentApi 方法;
- 移除 ColumnAttribute.Unique 属性设置,改为 IndexAttribute 特性设置唯一键;
This commit is contained in:
@ -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();
|
||||
}
|
||||
|
||||
|
21
FreeSql/DatabaseModel/DbIndexInfo.cs
Normal file
21
FreeSql/DatabaseModel/DbIndexInfo.cs
Normal 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; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user