【.net core】【sqlsugar】批量更新方法

官方文档:单表更新、更新数据 - SqlSugar 5x - .NET果糖网

泛型类中增加

cs 复制代码
//更新单个实体
public async Task<int> Update(TEntity entity)
{
    //IgnoreColumns(ignoreAllNullColumns: true):忽略设置为跳过的列
	return await _db.Updateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
}
//批量更新实体
public async Task<int> Update(List<TEntity> list)
{
    //此处不需要加.IgnoreColumns(ignoreAllNullColumns: true),增加该操作会导致更新不成功
    return await _db.Updateable(list).ExecuteCommandAsync();
}
相关推荐
睡前要喝豆奶粉2 小时前
.NET Core Web API中数据库相关配置
数据库·c#·.netcore
Archy_Wang_17 小时前
Hangfire 入门与实战:在 .NET Core 中实现可靠后台任务处理
c#·.netcore
睡前要喝豆奶粉1 天前
在.NET Core Web Api中使用redis
redis·c#·.netcore
睡前要喝豆奶粉2 天前
多表分页联查——EF Core方式和Dapper方式
c#·.netcore
csdn_aspnet2 天前
.NETCore、.NET 7 和 RabbitMQ 的发布-订阅模式
rabbitmq·.netcore·.net7.
爱吃香蕉的阿豪2 天前
深入理解 .NET Core 中的 IServiceScopeFactory:用法、场景与静态类依赖注入
.netcore
sky-stars3 天前
.NET 泛型编程(泛型类、泛型方法、泛型接口、泛型委托、泛型约束)
c#·.net·.netcore
The Sheep 20233 天前
.NetCoreMVC 开发网页使用sass
.netcore·sass
宝桥南山4 天前
.NET10 - 尝试一下Blazor Web Assembly Standalone App的fingerprint新特性
microsoft·微软·c#·asp.net·.net·.netcore
刚子编程6 天前
ASP.NET Core Blazor 核心功能一:Blazor依赖注入与状态管理指南
开发语言·.netcore·blazor