public async Task <int> DeleteLog(OperationTypeEnum categoryId, int keepTime) { DateTime operateTime = DateTime.Now; if (keepTime == 1)//保留近一周 { operateTime = DateTime.Now.AddDays(-7); } else if (keepTime == 2)//保留近一个月 { operateTime = DateTime.Now.AddMonths(-1); } else if (keepTime == 3)//保留近三个月 { operateTime = DateTime.Now.AddMonths(-3); } var expression = LinqExtensions.True <LogEntity>(); expression = expression.And(t => t.is_enabled == true && t.is_delete == false); expression = expression.And(t => t.operate_time <= operateTime && t.category_id == categoryId); LogEntity updateEntity = new LogEntity { is_delete = true, is_enabled = false }; return(await _service.BaseUpdate(expression, new LogEntity { is_delete = true }, new string[] { "is_delete" }.ToList())); }