From d8c4ff2395ecaac83c28ab890bb7bb49a7dcd2de Mon Sep 17 00:00:00 2001 From: sunkaixuna <610262374@qq.com> Date: Mon, 24 Jan 2022 08:31:43 +0800 Subject: [PATCH] Update .net --- .../DeleteProvider/LogicDeleteProvider.cs | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/Src/Asp.Net/SqlSugar/Abstract/DeleteProvider/LogicDeleteProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/DeleteProvider/LogicDeleteProvider.cs index 258ec7b31..05d46a1fa 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/DeleteProvider/LogicDeleteProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/DeleteProvider/LogicDeleteProvider.cs @@ -10,27 +10,42 @@ namespace SqlSugar { public DeleteableProvider Deleteable { get; set; } public DeleteBuilder DeleteBuilder { get; set; } - - public int ExecuteCommand(string LogicFieldName = null) + public int ExecuteCommand(string LogicFieldName = null,object deleteValue=null,string deleteTimeFieldName = null) { ISqlSugarClient db; List pars; string where; LogicFieldName = _ExecuteCommand(LogicFieldName, out db, out where, out pars); - var updateable = db.Updateable().SetColumns(LogicFieldName,true); + if (deleteValue == null) + { + deleteValue = true; + } + var updateable = db.Updateable().SetColumns(LogicFieldName, deleteValue); + if (deleteTimeFieldName != null) + { + updateable.SetColumns(deleteTimeFieldName, DateTime.Now); + } if (pars != null) updateable.UpdateBuilder.Parameters.AddRange(pars); Convert(updateable as UpdateableProvider); var result = updateable.Where(where).ExecuteCommand(); return result; } - public async Task ExecuteCommandAsync(string LogicFieldName = null) + public async Task ExecuteCommandAsync(string LogicFieldName = null, object deleteValue = null, string deleteTimeFieldName = null) { ISqlSugarClient db; List pars; string where; LogicFieldName = _ExecuteCommand(LogicFieldName, out db, out where, out pars); - var updateable = db.Updateable().SetColumns(LogicFieldName, true); + if (deleteValue == null) + { + deleteValue = true; + } + var updateable = db.Updateable().SetColumns(LogicFieldName, deleteValue); + if (deleteTimeFieldName != null) + { + updateable.SetColumns(deleteTimeFieldName, DateTime.Now); + } if (pars != null) updateable.UpdateBuilder.Parameters.AddRange(pars); Convert(updateable as UpdateableProvider);