mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 17:20:49 +08:00 
			
		
		
		
	- 优化 InsertOrUpdate AsType 使用错误的友好提示;
This commit is contained in:
		@@ -130,13 +130,6 @@
 | 
			
		||||
            清空状态数据
 | 
			
		||||
            </summary>
 | 
			
		||||
        </member>
 | 
			
		||||
        <member name="M:FreeSql.DbSet`1.RemoveAsync(System.Linq.Expressions.Expression{System.Func{`0,System.Boolean}})">
 | 
			
		||||
            <summary>
 | 
			
		||||
            根据 lambda 条件删除数据
 | 
			
		||||
            </summary>
 | 
			
		||||
            <param name="predicate"></param>
 | 
			
		||||
            <returns></returns>
 | 
			
		||||
        </member>
 | 
			
		||||
        <member name="M:FreeSql.DbSet`1.Add(`0)">
 | 
			
		||||
            <summary>
 | 
			
		||||
            添加
 | 
			
		||||
@@ -532,14 +525,5 @@
 | 
			
		||||
            <param name="that"></param>
 | 
			
		||||
            <returns></returns>
 | 
			
		||||
        </member>
 | 
			
		||||
        <member name="M:Microsoft.Extensions.DependencyInjection.FreeSqlRepositoryDependencyInjection.AddFreeRepository(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action{FreeSql.FluentDataFilter},System.Reflection.Assembly[])">
 | 
			
		||||
            <summary>
 | 
			
		||||
            批量注入 Repository,可以参考代码自行调整
 | 
			
		||||
            </summary>
 | 
			
		||||
            <param name="services"></param>
 | 
			
		||||
            <param name="globalDataFilter"></param>
 | 
			
		||||
            <param name="assemblies"></param>
 | 
			
		||||
            <returns></returns>
 | 
			
		||||
        </member>
 | 
			
		||||
    </members>
 | 
			
		||||
</doc>
 | 
			
		||||
 
 | 
			
		||||
@@ -72,30 +72,15 @@ namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
        public static void AuditDataValue(object sender, IEnumerable<T1> data, IFreeSql orm, TableInfo table, Dictionary<string, bool> changedDict)
 | 
			
		||||
        {
 | 
			
		||||
            if (data?.Any() != true) return;
 | 
			
		||||
            if (orm.Aop.AuditValueHandler == null) return;
 | 
			
		||||
            foreach (var d in data)
 | 
			
		||||
            {
 | 
			
		||||
                if (d == null) continue;
 | 
			
		||||
                foreach (var col in table.Columns.Values)
 | 
			
		||||
                {
 | 
			
		||||
                    object val = col.GetValue(d);
 | 
			
		||||
                    var auditArgs = new Aop.AuditValueEventArgs(Aop.AuditValueType.InsertOrUpdate, col, table.Properties[col.CsName], val);
 | 
			
		||||
                    orm.Aop.AuditValueHandler(sender, auditArgs);
 | 
			
		||||
                    if (auditArgs.ValueIsChanged)
 | 
			
		||||
                    {
 | 
			
		||||
                        col.SetValue(d, val = auditArgs.Value);
 | 
			
		||||
                        if (changedDict != null && changedDict.ContainsKey(col.Attribute.Name) == false)
 | 
			
		||||
                            changedDict.Add(col.Attribute.Name, true);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
                AuditDataValue(sender, d, orm, table, changedDict);
 | 
			
		||||
        }
 | 
			
		||||
        public static void AuditDataValue(object sender, T1 data, IFreeSql orm, TableInfo table, Dictionary<string, bool> changedDict)
 | 
			
		||||
        {
 | 
			
		||||
            if (orm.Aop.AuditValueHandler == null) return;
 | 
			
		||||
            if (data == null) return;
 | 
			
		||||
            if (typeof(T1) == typeof(object) && new[] { table.Type, table.TypeLazy }.Contains(data.GetType()) == false)
 | 
			
		||||
                throw new Exception($"操作的数据类型({data.GetType().DisplayCsharp()}) 与 AsType({table.Type.DisplayCsharp()}) 不一致,请检查。");
 | 
			
		||||
            if (orm.Aop.AuditValueHandler == null) return;
 | 
			
		||||
            foreach (var col in table.Columns.Values)
 | 
			
		||||
            {
 | 
			
		||||
                object val = col.GetValue(data);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user