mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 18:52:50 +08:00
- 优化 InsertOrUpdate AsType 使用错误的友好提示;
This commit is contained in:
parent
a9f9832b5c
commit
a634192af9
@ -130,13 +130,6 @@
|
|||||||
清空状态数据
|
清空状态数据
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</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)">
|
<member name="M:FreeSql.DbSet`1.Add(`0)">
|
||||||
<summary>
|
<summary>
|
||||||
添加
|
添加
|
||||||
@ -532,14 +525,5 @@
|
|||||||
<param name="that"></param>
|
<param name="that"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</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>
|
</members>
|
||||||
</doc>
|
</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)
|
public static void AuditDataValue(object sender, IEnumerable<T1> data, IFreeSql orm, TableInfo table, Dictionary<string, bool> changedDict)
|
||||||
{
|
{
|
||||||
if (data?.Any() != true) return;
|
if (data?.Any() != true) return;
|
||||||
if (orm.Aop.AuditValueHandler == null) return;
|
|
||||||
foreach (var d in data)
|
foreach (var d in data)
|
||||||
{
|
AuditDataValue(sender, d, orm, table, changedDict);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public static void AuditDataValue(object sender, T1 data, IFreeSql orm, TableInfo table, Dictionary<string, bool> 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 (data == null) return;
|
||||||
if (typeof(T1) == typeof(object) && new[] { table.Type, table.TypeLazy }.Contains(data.GetType()) == false)
|
if (typeof(T1) == typeof(object) && new[] { table.Type, table.TypeLazy }.Contains(data.GetType()) == false)
|
||||||
throw new Exception($"操作的数据类型({data.GetType().DisplayCsharp()}) 与 AsType({table.Type.DisplayCsharp()}) 不一致,请检查。");
|
throw new Exception($"操作的数据类型({data.GetType().DisplayCsharp()}) 与 AsType({table.Type.DisplayCsharp()}) 不一致,请检查。");
|
||||||
|
if (orm.Aop.AuditValueHandler == null) return;
|
||||||
foreach (var col in table.Columns.Values)
|
foreach (var col in table.Columns.Values)
|
||||||
{
|
{
|
||||||
object val = col.GetValue(data);
|
object val = col.GetValue(data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user