【.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();
}
相关推荐
csdn_aspnet4 天前
.NetCore Webapi 接口验证请求来源
.netcore·ip·token·签名·webapi·cors·sign
宝桥南山7 天前
Microsoft Fabric - 简单尝试一下Microsoft Fabric .NET SDK
microsoft·微软·.net·.netcore·powerbi·fabric
geovindu8 天前
CSharp:Condition Variable Pattern
后端·设计模式·c#·.net·.netcore·条件变量模式·同步型模式
geovindu12 天前
CSharp: Observer Pattern
开发语言·后端·观察者模式·设计模式·c#·.netcore·行为模式
geovindu13 天前
CSharp: Strategy Pattern
开发语言·后端·c#·.net·.netcore·策略模式·行为模式
geovindu13 天前
CSharp: Task Scheduler
开发语言·后端·c#·.net·.netcore
geovindu19 天前
CSharp: Wordcloud
开发语言·后端·c#·.net·.netcore·词云
geovindu19 天前
CSharp: Command Pattern
开发语言·后端·c#·.net·.netcore·命令模式·行为模式
全栈小51 个月前
【C#】.net core,静态方法线程安全解析,面试时经常被问的线程安全就藏在里面
安全·c#·.netcore
清风与日月1 个月前
Yitter.IdGenerator:高性能分布式唯一ID生成器详解
分布式·c#·.net·.netcore