mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-03-03 00:00:58 +08:00
- 在 DbConnOptions 新增 EnabledConcurrencyException(bool,默认 false) 配置项。 - 在 SqlSugarRepository 引入 IAbpLazyServiceProvider,通过 IOptions<DbConnOptions> 延迟获取配置。 - UpdateAsync 改为仅当 EnabledConcurrencyException 为 true 且实体实现 IHasConcurrencyStamp 时,使用 ExecuteCommandWithOptLockAsync 并捕获 VersionExceptions 抛出 AbpDbConcurrencyException;否则回退到原有的 UpdateAsync 实现。 - 清理/调整部分 using 引用,新增 Microsoft.Extensions.Options 与 Volo.Abp.DependencyInjection 引用。 注意:默认值为 false,需在配置中显式开启 EnabledConcurrencyException 才会启用乐观并发校验,开启后会改变之前对带版本实体自动使用乐观锁的行为。
67 lines
1.9 KiB
C#
67 lines
1.9 KiB
C#
using SqlSugar;
|
|
using ArgumentException = System.ArgumentException;
|
|
|
|
namespace Yi.Framework.SqlSugarCore.Abstractions
|
|
{
|
|
/// <summary>
|
|
/// 数据库连接配置选项
|
|
/// </summary>
|
|
public class DbConnOptions
|
|
{
|
|
/// <summary>
|
|
/// 主数据库连接字符串
|
|
/// 如果开启多租户,此为默认租户数据库
|
|
/// </summary>
|
|
public string? Url { get; set; }
|
|
|
|
/// <summary>
|
|
/// 数据库类型
|
|
/// </summary>
|
|
public DbType? DbType { get; set; }
|
|
|
|
/// <summary>
|
|
/// 是否启用种子数据初始化
|
|
/// </summary>
|
|
public bool EnabledDbSeed { get; set; } = false;
|
|
|
|
/// <summary>
|
|
/// 是否启用驼峰命名转下划线命名
|
|
/// </summary>
|
|
public bool EnableUnderLine { get; set; } = false;
|
|
|
|
/// <summary>
|
|
/// 是否启用Code First模式
|
|
/// </summary>
|
|
public bool EnabledCodeFirst { get; set; } = false;
|
|
|
|
/// <summary>
|
|
/// 是否启用SQL日志记录
|
|
/// </summary>
|
|
public bool EnabledSqlLog { get; set; } = true;
|
|
|
|
/// <summary>
|
|
/// 实体类所在程序集名称列表
|
|
/// </summary>
|
|
public List<string>? EntityAssembly { get; set; }
|
|
|
|
/// <summary>
|
|
/// 是否启用读写分离
|
|
/// </summary>
|
|
public bool EnabledReadWrite { get; set; } = false;
|
|
|
|
/// <summary>
|
|
/// 只读数据库连接字符串列表
|
|
/// </summary>
|
|
public List<string>? ReadUrl { get; set; }
|
|
|
|
/// <summary>
|
|
/// 是否启用SaaS多租户
|
|
/// </summary>
|
|
public bool EnabledSaasMultiTenancy { get; set; } = false;
|
|
|
|
/// <summary>
|
|
/// 是否开启更新并发乐观锁
|
|
/// </summary>
|
|
public bool EnabledConcurrencyException { get;set; } = false;
|
|
}
|
|
} |