Skip to content

Commit 2e6be8b

Browse files
committed
- 修复 AOP 优先级最高 Aop.ConfigEntity 无法获取 ModifyIndexResult 的问题;
1 parent 8a8b730 commit 2e6be8b

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

FreeSql/Interface/IAop.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public ConfigEntityEventArgs(Type entityType)
138138
/// <summary>
139139
/// 索引配置
140140
/// </summary>
141-
public List<IndexAttribute> ModifyIndexResult { get; }
141+
public List<IndexAttribute> ModifyIndexResult { get; internal set; }
142142
}
143143
public class ConfigEntityPropertyEventArgs : EventArgs
144144
{

FreeSql/Internal/CommonUtils.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,13 @@ public TableAttribute GetEntityTableAttribute(Type type)
175175
case MappingPriorityType.Aop:
176176
if (_orm.Aop.ConfigEntityHandler != null)
177177
{
178+
var aopeIndexsPriorityTypes = new List<MappingPriorityType>();
179+
foreach (var aipt in _mappingPriorityTypes)
180+
{
181+
if (aipt == MappingPriorityType.Aop) break;
182+
else aopeIndexsPriorityTypes.Add(aipt);
183+
}
184+
var aopeIndexs = GetEntityIndexAttribute(type, aopeIndexsPriorityTypes.ToArray());
178185
var aope = new Aop.ConfigEntityEventArgs(type)
179186
{
180187
ModifyResult = new TableAttribute
@@ -183,7 +190,8 @@ public TableAttribute GetEntityTableAttribute(Type type)
183190
OldName = attr.OldName,
184191
_DisableSyncStructure = attr._DisableSyncStructure,
185192
AsTable = attr.AsTable
186-
}
193+
},
194+
ModifyIndexResult = aopeIndexs.ToList()
187195
};
188196
_orm.Aop.ConfigEntityHandler(_orm, aope);
189197
var tryattr = aope.ModifyResult;
@@ -412,10 +420,11 @@ public NavigateAttribute GetEntityNavigateAttribute(Type type, PropertyInfo prot
412420
if (attr.ManyToMany != null) ret = attr;
413421
return ret;
414422
}
415-
public IndexAttribute[] GetEntityIndexAttribute(Type type)
423+
public IndexAttribute[] GetEntityIndexAttribute(Type type, MappingPriorityType[] mappingPriorityTypes)
416424
{
425+
if (mappingPriorityTypes == null) mappingPriorityTypes = _mappingPriorityTypes;
417426
var ret = new Dictionary<string, IndexAttribute>();
418-
foreach (var mp in _mappingPriorityTypes)
427+
foreach (var mp in mappingPriorityTypes)
419428
{
420429
switch (mp)
421430
{

0 commit comments

Comments
 (0)