mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 17:20:49 +08:00 
			
		
		
		
	- 优化 主键 Guid 自动赋值的优先级,低于 Aop.AuditValue 事件(实现自定义 Guid 值);#274
This commit is contained in:
		@@ -139,6 +139,17 @@ namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
            foreach (var col in table.Columns.Values)
 | 
			
		||||
            {
 | 
			
		||||
                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.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);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user