替换Sqlsugar默认序列化器,解决.Select()映射嵌套/匿名类时,实体的非公有访问器 值无法绑定,如Id(protect属性)

This commit is contained in:
bi8bo
2024-08-30 14:41:45 +08:00
parent bfe0f346c8
commit e3aada0fff
3 changed files with 83 additions and 2 deletions

View File

@@ -40,6 +40,9 @@ namespace Yi.Framework.SqlSugarCore
public IEntityChangeEventHelper EntityChangeEventHelper => LazyServiceProvider.LazyGetService<IEntityChangeEventHelper>(NullEntityChangeEventHelper.Instance);
public DbConnOptions Options => LazyServiceProvider.LazyGetRequiredService<IOptions<DbConnOptions>>().Value;
public AbpDbConnectionOptions ConnectionOptions => LazyServiceProvider.LazyGetRequiredService<IOptions<AbpDbConnectionOptions>>().Value;
public ISerializeService SerializeService=> LazyServiceProvider.LazyGetRequiredService<ISerializeService>();
private ISqlSugarDbConnectionCreator _dbConnectionCreator;
public void SetSqlSugarClient(ISqlSugarClient sqlSugarClient)
@@ -63,6 +66,8 @@ namespace Yi.Framework.SqlSugarCore
options.DbType = GetCurrentDbType();
}));
connectionCreator.SetDbAop(SqlSugarClient);
//替换默认序列化器
SqlSugarClient.CurrentConnectionConfig.ConfigureExternalServices.SerializeService = SerializeService;
}
/// <summary>