Skip to content

Commit 8559c67

Browse files
committed
- 修复 Aop.ConfigEntity 对索引特性的重写;
1 parent 0b18c66 commit 8559c67

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

FreeSql/Internal/CommonUtils.cs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,13 @@ public TableAttribute GetEntityTableAttribute(Type type)
175175
case MappingPriorityType.Aop:
176176
if (_orm.Aop.ConfigEntityHandler != null)
177177
{
178-
var aopeIndexsPriorityTypes = new List<MappingPriorityType>();
178+
var aopBeforeTypes = new List<MappingPriorityType>();
179179
foreach (var aipt in _mappingPriorityTypes)
180180
{
181181
if (aipt == MappingPriorityType.Aop) break;
182-
else aopeIndexsPriorityTypes.Add(aipt);
182+
else aopBeforeTypes.Add(aipt);
183183
}
184-
var aopeIndexs = GetEntityIndexAttribute(type, aopeIndexsPriorityTypes.ToArray());
184+
var aopeIndexs = GetEntityIndexAttribute(type, aopBeforeTypes);
185185
var aope = new Aop.ConfigEntityEventArgs(type)
186186
{
187187
ModifyResult = new TableAttribute
@@ -420,7 +420,25 @@ public NavigateAttribute GetEntityNavigateAttribute(Type type, PropertyInfo prot
420420
if (attr.ManyToMany != null) ret = attr;
421421
return ret;
422422
}
423-
public IndexAttribute[] GetEntityIndexAttribute(Type type, MappingPriorityType[] mappingPriorityTypes = null)
423+
public IndexAttribute[] GetEntityIndexAttribute(Type type)
424+
{
425+
//计算 Aop 优先级后面的配置
426+
var aopAfterTypes = new List<MappingPriorityType>();
427+
var isAopFirst = false;
428+
foreach (var aipt in _mappingPriorityTypes)
429+
{
430+
if (aipt == MappingPriorityType.Aop)
431+
{
432+
isAopFirst = true;
433+
aopAfterTypes.Add(aipt);
434+
continue;
435+
}
436+
if (isAopFirst) aopAfterTypes.Add(aipt);
437+
}
438+
var indexs = GetEntityIndexAttribute(type, aopAfterTypes);
439+
return indexs;
440+
}
441+
IndexAttribute[] GetEntityIndexAttribute(Type type, IEnumerable<MappingPriorityType> mappingPriorityTypes)
424442
{
425443
if (mappingPriorityTypes == null) mappingPriorityTypes = _mappingPriorityTypes;
426444
var ret = new Dictionary<string, IndexAttribute>();

0 commit comments

Comments
 (0)