一、单条记录设置软删除:可同时设置记录是否可启用
////// 设置删除标志 /// /// 主键 /// 修改有效状态 /// 记录修改者 ///影响行数 public virtual int SetDeleted(object id, bool changeEnabled = false, bool recordModifiedUser = false) { List> parameters = new List >(); parameters.Add(new KeyValuePair (BaseBusinessLogic.FieldDeletionStateCode, 1)); if (changeEnabled) { parameters.Add(new KeyValuePair (BaseBusinessLogic.FieldEnabled, 0)); } if (recordModifiedUser && this.UserInfo != null) { parameters.Add(new KeyValuePair (BaseBusinessLogic.FieldModifiedUserId, this.UserInfo.Id)); //宋彪发现这里的错误 文字与格式字符串错误 //parameters.Add(new KeyValuePair (BaseBusinessLogic.FieldModifiedOn, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))); parameters.Add(new KeyValuePair (BaseBusinessLogic.FieldModifiedOn, DateTime.Now)); } return this.SetProperty(new KeyValuePair (this.PrimaryKey, id), parameters); }
public virtual int SetProperty(KeyValuePairwhereParameter, List > parameters) { List > whereParameters = new List >(); whereParameters.Add(whereParameter); return DbLogic.SetProperty(DbHelper, this.CurrentTableName, whereParameters, parameters); }
二、多条记录设置软删除标志:可同时设置记录是否可启用
////// 批量删除标志 /// /// 主键数组 /// 有效 /// 修改者 ///影响行数 public virtual int SetDeleted(object[] ids, bool enabled = false, bool modifiedUser = false) { List> parameters = new List >(); parameters.Add(new KeyValuePair (BaseBusinessLogic.FieldDeletionStateCode, 1)); if (enabled) { parameters.Add(new KeyValuePair (BaseBusinessLogic.FieldEnabled, 0)); } if (modifiedUser && this.UserInfo != null) { parameters.Add(new KeyValuePair (BaseBusinessLogic.FieldModifiedUserId, this.UserInfo.Id)); parameters.Add(new KeyValuePair (BaseBusinessLogic.FieldModifiedBy, this.UserInfo.RealName)); parameters.Add(new KeyValuePair (BaseBusinessLogic.FieldModifiedOn, DateTime.Now)); } return this.SetProperty(ids, parameters); }
public virtual int SetProperty(object[] ids, List> parameters) { return this.SetProperty(this.PrimaryKey, ids, parameters); }
public virtual int SetProperty(string name, object[] values, List> parameters) { int result = 0; if (values == null) { result += this.SetProperty(new KeyValuePair (name, string.Empty), parameters); } else { for (int i = 0; i < values.Length; i++) { result += this.SetProperty(new KeyValuePair (name, values[i]), parameters); } } return result; }
public virtual int SetProperty(KeyValuePairwhereParameter, List > parameters) { List > whereParameters = new List >(); whereParameters.Add(whereParameter); return DbLogic.SetProperty(DbHelper, this.CurrentTableName, whereParameters, parameters); }