mirror of
https://github.com/dotnetcore/FreeSql.git
synced 2026-02-12 11:20:56 +08:00
- 修复 AOP 优先级最高 Aop.ConfigEntity 无法获取 ModifyIndexResult 的问题;
This commit is contained in:
@@ -138,7 +138,7 @@ namespace FreeSql.Aop
|
||||
/// <summary>
|
||||
/// 索引配置
|
||||
/// </summary>
|
||||
public List<IndexAttribute> ModifyIndexResult { get; }
|
||||
public List<IndexAttribute> ModifyIndexResult { get; internal set; }
|
||||
}
|
||||
public class ConfigEntityPropertyEventArgs : EventArgs
|
||||
{
|
||||
|
||||
@@ -175,6 +175,13 @@ namespace FreeSql.Internal
|
||||
case MappingPriorityType.Aop:
|
||||
if (_orm.Aop.ConfigEntityHandler != null)
|
||||
{
|
||||
var aopeIndexsPriorityTypes = new List<MappingPriorityType>();
|
||||
foreach (var aipt in _mappingPriorityTypes)
|
||||
{
|
||||
if (aipt == MappingPriorityType.Aop) break;
|
||||
else aopeIndexsPriorityTypes.Add(aipt);
|
||||
}
|
||||
var aopeIndexs = GetEntityIndexAttribute(type, aopeIndexsPriorityTypes.ToArray());
|
||||
var aope = new Aop.ConfigEntityEventArgs(type)
|
||||
{
|
||||
ModifyResult = new TableAttribute
|
||||
@@ -183,7 +190,8 @@ namespace FreeSql.Internal
|
||||
OldName = attr.OldName,
|
||||
_DisableSyncStructure = attr._DisableSyncStructure,
|
||||
AsTable = attr.AsTable
|
||||
}
|
||||
},
|
||||
ModifyIndexResult = aopeIndexs.ToList()
|
||||
};
|
||||
_orm.Aop.ConfigEntityHandler(_orm, aope);
|
||||
var tryattr = aope.ModifyResult;
|
||||
@@ -412,10 +420,11 @@ namespace FreeSql.Internal
|
||||
if (attr.ManyToMany != null) ret = attr;
|
||||
return ret;
|
||||
}
|
||||
public IndexAttribute[] GetEntityIndexAttribute(Type type)
|
||||
public IndexAttribute[] GetEntityIndexAttribute(Type type, MappingPriorityType[] mappingPriorityTypes)
|
||||
{
|
||||
if (mappingPriorityTypes == null) mappingPriorityTypes = _mappingPriorityTypes;
|
||||
var ret = new Dictionary<string, IndexAttribute>();
|
||||
foreach (var mp in _mappingPriorityTypes)
|
||||
foreach (var mp in mappingPriorityTypes)
|
||||
{
|
||||
switch (mp)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user