Liwendong.Frameworks.Data.SqlSugarExtend
3.2.1
.NET 8.0
This package targets .NET 8.0. The package is compatible with this framework or higher.
.NET Core 3.1
This package targets .NET Core 3.1. The package is compatible with this framework or higher.
.NET Framework 4.5.1
This package targets .NET Framework 4.5.1. The package is compatible with this framework or higher.
dotnet add package Liwendong.Frameworks.Data.SqlSugarExtend --version 3.2.1
NuGet\Install-Package Liwendong.Frameworks.Data.SqlSugarExtend -Version 3.2.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Liwendong.Frameworks.Data.SqlSugarExtend" Version="3.2.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Liwendong.Frameworks.Data.SqlSugarExtend" Version="3.2.1" />
<PackageReference Include="Liwendong.Frameworks.Data.SqlSugarExtend" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Liwendong.Frameworks.Data.SqlSugarExtend --version 3.2.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Liwendong.Frameworks.Data.SqlSugarExtend, 3.2.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Liwendong.Frameworks.Data.SqlSugarExtend@3.2.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Liwendong.Frameworks.Data.SqlSugarExtend&version=3.2.1
#tool nuget:?package=Liwendong.Frameworks.Data.SqlSugarExtend&version=3.2.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Liwendong.Frameworks.Data.SqlSugarExtend
主要是基于 SqlSugar 进行扩展操作
更新日志
版本历史
3.2.1 (2026-10-17)
- 修复:
NormalizeDuration三元两分支相同,未限制有效期时正确返回int.MaxValue - 修复:
Update(info, List<string> columns)更新列被主键过滤后为空时误退化为全列更新,改为直接不执行 - 修复:
SetOrderBy排序项已带 ASC/DESC 时重复追加方向生成ORDER BY Id DESC Asc,改为仅在排序项缺省方向时追加 - 修复:
UpdateIgnoreColumn(T, ...)两个重载补info == null判空(对齐Update(T)) - 修复:
UseTran事务失败且ErrorException为 null 时throw抛 NRE,改为抛EasyErrorException("事务执行失败");泛型/非泛型两处实现收敛为SqlSugarDb.ExecuteTranCore - 修复:
GetUpdateColumnName/GetNotUpdateColumnName会把默认排除列AddRange进调用方传入的列表(副作用),改为先拷贝再操作;补source/info判空,删除未使用局部变量 - 修复:
BaseQueryParameter.OrderBySql缓存先写 key 后写内容的竞态,改为先算结果 → 写缓存 → 最后写 key - 修复:
SqlSugarDb慢 SQL AOP 回调中client == null判断恒假,改为判_disposed - 修复:慢 SQL 阈值
SqlSugarDb20000ms 与SqlSugarConfig5000ms 不一致,统一为 5000ms - 修复:
GetInfo排序默认值SqlSugarBLLBase(Desc)与SugarHandler(Asc)不一致,统一为 Asc(注意:依赖 Desc 默认排序的调用方需显式传OrderByType.Desc) - 修复:
SqlSugarDALBase未配置ConnectionStrings:default时给出明确报错"ConnectionStrings:default 未配置" - 优化:
MemoryCache/RedisCache的GetOrCreate逐字重复实现抽取为SqlSugarHelper.GetOrCreateCacheItem - 优化:
GetUpdateColumnName两个重载的属性比对循环抽取为DiffUpdateColumns;Update(T,Action,...)与UpdateIgnoreColumn(T,Action,...)抽取为UpdateByChangedColumns - 优化:批量
Update的UpdateColumns/WhereColumns/SetColumns返回值处理风格统一(全部回写) - 优化:
SqlSugarIFWhereOption、SqlSugarOrderByOption补充 XML 注释 - 不兼容变更:
Extensions.Pager返回类型由void改为ISugarQueryable<T>(可链式调用,不再依赖可变语义;源码兼容,重新编译即可,二进制不兼容)
3.2.0
目标框架扩展版本,无行为变更。
新增
- 目标框架由
netcoreapp3.1;net451;net46;net48扩展为net8.0;netcoreapp3.1;net451;net46;net47;net48;net8.0 与 netcoreapp3.1 同档使用 SqlSugarCore 5.1.4.198(API 行为一致),.NET Framework 侧沿用 SqlSugar 5.1.4.198。
3.1.0
本次为缺陷修复版本,包含少量不兼容变更,升级请留意下方说明。
修复
- 缓存失效不完整:
UpdateSetColumn全部重载、Add(Dictionary<string,object>)之前未调用RemoveDataCache, 开启EnabledCache后会一直读到脏数据(SqlSugar 缓存默认有效期为 int.MaxValue 秒)。现已全部补齐。 - 全表删除/更新风险:
Delete(Expression)、Delete(BaseQueryParameter)、Update(Dictionary, where)、UpdateSetColumn(wheres, ...)、Any、GetInfo、GetList在条件为 null 时不再默认执行全表操作,改为抛出ArgumentNullException。确实需要操作全部数据时,请显式传入it => true。 - 连接泄漏:
SqlSugarDb实现IDisposable;调用方传入的ConnectionConfig会按配置兜底开启IsAutoCloseConnection(SqlSugar 默认为 false)。 - ORDER BY 注入面:
BaseQueryParameter.OrderBySql由黑名单过滤改为白名单校验, 仅接受字段名 [ASC|DESC](多个字段逗号分隔),非法内容直接丢弃。 - 日志安全:慢 SQL / SQL 异常日志默认不再记录参数值,避免手机号、身份证、Token 等敏感数据落盘;
需要排查问题时可开启
SqlSugarConfig:LogSqlParameterValue。SQL 异常日志由 Warn 级别改为 Exception 级别。 - 主键过滤失效:
Update(info, List<string> columns)之前用"数据库列名"过滤"实体属性名", 实体存在SugarColumn(ColumnName=...)时主键排除不生效,现改为按属性名匹配(新增GetPrimaryKeyPropertyNames)。 - 变更检测失效:
Update(info, Action, ...)之前使用浅拷贝快照,引用类型属性与源对象共享实例导致修改检测不到, 现改为深拷贝(SqlSugarHelper.CloneEntity,内部用序列化实现,循环引用已处理,失败时降级为浅拷贝)。 - 表达式解析遗漏:
GetColumnName/UpdateIgnoreColumn之前不处理装箱产生的UnaryExpression, 传入值类型属性(如x => x.Id)时会被静默忽略;现已统一由GetMemberNames处理。 - 空引用与空集合:补齐
Update(info, columns)、Update(List)、UpdateIgnoreColumn(List)、Add(Dictionary)、RemoveCache等方法的判空保护;移除RemoveCache中可能对非线程安全缓存实现的并发访问。 - Redis 资源与竞态:
RedisCache按连接串复用实例,避免重复触发CSRedisCoreHelper全局初始化。 - 配置污染:不再修改全局静态的
SqlConfig.SqlSugarConfig.RedisConfig.ConnectionString;ConfigureExternalServices由覆盖改为合并,保留调用方自定义配置。 NotAny由Func<T,bool>改为Expression<Func<T,bool>>,原写法无法被翻译成 SQL。
不兼容变更
SqlSugarBLLBase的Add/Update/UpdateIgnoreColumn/UpdateSetColumn返回值由void改为bool。 忽略返回值的调用代码无需改动;若有派生类重写了这些方法,需要同步修改返回类型。NotAny参数类型由Func<T,bool>改为Expression<Func<T,bool>>(lambda 写法不变)。Delete/Update(Dictionary)/UpdateSetColumn在缺少条件时由"执行全表操作"改为抛出异常。BaseQueryParameter.OrderBySql不再支持Id DESC, CASE WHEN ...这类表达式写法,仅接受字段名与排序方向。- 慢 SQL / SQL 异常日志默认不再输出参数值。
新增配置项(SqlSugarConfig 节点)
| 配置 | 默认值 | 说明 |
|---|---|---|
LogSqlParameterValue |
false | 是否在日志中输出 SQL 参数值 |
EnabledSlowSqlLog |
true | 是否输出慢 SQL 日志 |
ForceAutoCloseConnection |
true | 是否兜底开启自动关闭连接 |
静态项 SqlSugarCacheOptions.MaxCacheDurationSeconds(默认 0 表示不限制)可用于限制单条缓存的最长有效期,
作为缓存未被失效时的兜底手段。
注意:
SqlSugarClient非线程安全,请勿在多线程间共享同一个SqlSugarDb/SugarHandler<T>实例; 不再使用时请调用Dispose()释放数据库连接。
3.0.0
- [3.0.0] 重新优化了继承方法,减去没有必要的继承
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.1 is compatible. |
| .NET Framework | net451 is compatible. net452 was computed. net46 is compatible. net461 was computed. net462 was computed. net463 was computed. net47 is compatible. net471 was computed. net472 was computed. net48 is compatible. net481 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETCoreApp 3.1
- Liwendong.CacheExtend.CSRedis (>= 1.1.2)
- Liwendong.Frameworks.Data (>= 1.5.2)
- SqlSugarCore (>= 5.1.4.198)
-
.NETFramework 4.5.1
- Liwendong.CacheExtend.CSRedis (>= 1.1.2)
- Liwendong.Frameworks.Data (>= 1.5.2)
- SqlSugar (>= 5.1.4.198)
-
.NETFramework 4.6
- Liwendong.CacheExtend.CSRedis (>= 1.1.2)
- Liwendong.Frameworks.Data (>= 1.5.2)
- SqlSugar (>= 5.1.4.198)
-
.NETFramework 4.7
- Liwendong.CacheExtend.CSRedis (>= 1.1.2)
- Liwendong.Frameworks.Data (>= 1.5.2)
- SqlSugar (>= 5.1.4.198)
-
.NETFramework 4.8
- Liwendong.CacheExtend.CSRedis (>= 1.1.2)
- Liwendong.Frameworks.Data (>= 1.5.2)
- SqlSugar (>= 5.1.4.198)
-
net8.0
- Liwendong.CacheExtend.CSRedis (>= 1.1.2)
- Liwendong.Frameworks.Data (>= 1.5.2)
- SqlSugarCore (>= 5.1.4.198)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 3.2.1 | 74 | 10/20/2026 | |
| 3.0.1 | 159 | 8/14/2026 | |
| 3.0.0 | 141 | 8/14/2026 | |
| 2.4.5 | 164 | 5/11/2026 | |
| 2.4.4 | 150 | 5/9/2026 | |
| 2.4.3 | 155 | 5/9/2026 | |
| 2.4.1 | 334 | 9/29/2025 | |
| 2.4.0 | 321 | 9/1/2025 | |
| 2.3.0 | 367 | 8/26/2025 | |
| 2.2.4 | 368 | 8/26/2025 | |
| 2.2.3 | 222 | 8/23/2025 | |
| 2.2.2 | 294 | 8/12/2025 | |
| 2.2.1 | 349 | 8/8/2025 | |
| 2.2.0 | 360 | 8/8/2025 | |
| 2.1.1 | 190 | 8/2/2025 | |
| 2.1.0 | 180 | 8/2/2025 | |
| 2.0.1 | 256 | 7/29/2025 | |
| 2.0.0 | 624 | 7/24/2025 | |
| 1.6.0 | 582 | 7/21/2025 | |
| 1.5.0 | 342 | 5/6/2025 |
Loading failed
修复缓存失效不全、全表更新删除风险、连接泄漏、ORDER BY注入面;详见 readme.md