From 4a4296993298d6bb222b18432e10d70aa82490a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com> Date: Sat, 25 Dec 2021 12:06:00 +0800 Subject: [PATCH] =?UTF-8?q?BaseRepository=20=E6=96=B0=E5=A2=9E=E5=A4=87?= =?UTF-8?q?=E6=B3=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ZR.Repository/BaseRepository.cs | 14 ++++++++++++++ ZR.Service/BaseService.cs | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/ZR.Repository/BaseRepository.cs b/ZR.Repository/BaseRepository.cs index 5dceae3..f19a0b0 100644 --- a/ZR.Repository/BaseRepository.cs +++ b/ZR.Repository/BaseRepository.cs @@ -131,6 +131,13 @@ namespace ZR.Repository return Context.Updateable(entity).UpdateColumns(expression).IgnoreColumns(ignoreAllNull).ExecuteCommand(); } + /// + /// 根据实体类更新 eg:Update(dept, it => new { it.Status }, f => depts.Contains(f.DeptId));只更新Status列,条件是包含 + /// + /// + /// + /// + /// public int Update(T entity, Expression> expression, Expression> where) { return Context.Updateable(entity).UpdateColumns(expression).Where(where).ExecuteCommand(); @@ -169,6 +176,13 @@ namespace ZR.Repository // }); // return result.IsSuccess; //} + + /// + /// 更新指定列 eg:Update(w => w.NoticeId == model.NoticeId, it => new SysNotice(){ Update_time = DateTime.Now, Title = "通知标题" }); + /// + /// + /// + /// public int Update(Expression> where, Expression> columns) { return Context.Updateable().SetColumns(columns).Where(where).RemoveDataCache().ExecuteCommand(); diff --git a/ZR.Service/BaseService.cs b/ZR.Service/BaseService.cs index 9c109fc..bf3e927 100644 --- a/ZR.Service/BaseService.cs +++ b/ZR.Service/BaseService.cs @@ -132,6 +132,13 @@ namespace ZR.Service return baseRepository.Update(entity, expression, ignoreAllNull); } + /// + /// 根据实体类更新 eg:Update(dept, it => new { it.Status }, f => depts.Contains(f.DeptId));只更新Status列,条件是包含 + /// + /// + /// + /// + /// public int Update(T entity, Expression> expression, Expression> where) { return baseRepository.Update(entity, expression, where); @@ -171,6 +178,13 @@ namespace ZR.Service // }); // return result.IsSuccess; //} + + /// + /// 更新指定列 eg:Update(w => w.NoticeId == model.NoticeId, it => new SysNotice(){ Update_time = DateTime.Now, Title = "通知标题" }); + /// + /// + /// + /// public int Update(Expression> where, Expression> columns) { return baseRepository.Update(where, columns);