mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 02:32:50 +08:00
- 优化 主键 Guid 自动赋值的优先级,低于 Aop.AuditValue 事件(实现自定义 Guid 值);#274
This commit is contained in:
parent
f8fa15054c
commit
9ad454376e
@ -139,6 +139,17 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
foreach (var col in table.Columns.Values)
|
foreach (var col in table.Columns.Values)
|
||||||
{
|
{
|
||||||
object val = col.GetMapValue(data);
|
object val = col.GetMapValue(data);
|
||||||
|
if (orm.Aop.AuditValueHandler != null)
|
||||||
|
{
|
||||||
|
var auditArgs = new Aop.AuditValueEventArgs(Aop.AuditValueType.Insert, col, table.Properties[col.CsName], val);
|
||||||
|
orm.Aop.AuditValueHandler(sender, auditArgs);
|
||||||
|
if (auditArgs.IsChanged)
|
||||||
|
{
|
||||||
|
col.SetMapValue(data, val = auditArgs.Value);
|
||||||
|
if (changedDict != null && changedDict.ContainsKey(col.Attribute.Name) == false)
|
||||||
|
changedDict.Add(col.Attribute.Name, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (col.Attribute.IsPrimary)
|
if (col.Attribute.IsPrimary)
|
||||||
{
|
{
|
||||||
if (col.Attribute.MapType.NullableTypeOrThis() == typeof(Guid) && (val == null || (Guid)val == Guid.Empty))
|
if (col.Attribute.MapType.NullableTypeOrThis() == typeof(Guid) && (val == null || (Guid)val == Guid.Empty))
|
||||||
@ -153,17 +164,6 @@ namespace FreeSql.Internal.CommonProvider
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (orm.Aop.AuditValueHandler != null)
|
|
||||||
{
|
|
||||||
var auditArgs = new Aop.AuditValueEventArgs(Aop.AuditValueType.Insert, col, table.Properties[col.CsName], val);
|
|
||||||
orm.Aop.AuditValueHandler(sender, auditArgs);
|
|
||||||
if (auditArgs.IsChanged)
|
|
||||||
{
|
|
||||||
col.SetMapValue(data, val = auditArgs.Value);
|
|
||||||
if (changedDict != null && changedDict.ContainsKey(col.Attribute.Name) == false)
|
|
||||||
changedDict.Add(col.Attribute.Name, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user