/// <summary> /// 更新语句后处理(单个实体操作不引发) /// </summary> /// <param name="condition">执行条件</param> /// <param name="args">参数值</param> /// <param name="operatorType">操作类型</param> private void OnOperatorExecutd(string condition, IEnumerable <MySqlParameter> args, DataOperatorType operatorType) { var mySqlParameters = args as MySqlParameter[] ?? args.ToArray(); OnOperatorExecutd(operatorType, condition, mySqlParameters); DataUpdateHandler.OnOperatorExecutd(TableId, condition, mySqlParameters, operatorType); }
/// <summary> /// 与更新同时执行的SQL(更新之后立即执行) /// </summary> /// <param name="condition">当前场景的执行条件</param> /// <returns></returns> private string AfterUpdateSql(string condition) { var code = new StringBuilder(); AfterUpdateSql(code, condition); DataUpdateHandler.AfterUpdateSql(this, code, TableId, condition); return(code.ToString()); }
/// <summary> /// 得到可正确拼接的SQL条件语句(可能是没有) /// </summary> /// <param name="condition"></param> /// <returns></returns> private string ContitionSqlCode(string condition) { List <string> conditions = new List <string>(); if (!_baseConditionInited) { InitBaseCondition(); _baseConditionInited = true; } if (!string.IsNullOrEmpty(BaseCondition)) { conditions.Add(BaseCondition); } if (!string.IsNullOrEmpty(condition)) { conditions.Add(condition); } ContitionSqlCode(conditions); DataUpdateHandler.ContitionSqlCode <TData>(TableId, conditions); if (conditions.Count == 0) { return(null); } var code = new StringBuilder(); bool isFirst = true; foreach (var con in conditions) { if (isFirst) { isFirst = false; code.Append("\nWHERE "); } else { code.Append(" AND "); } code.Append($"({con})"); } return(code.ToString()); }
/// <summary> /// 保存完成后期处理 /// </summary> /// <param name="entity">保存的对象</param> /// <param name="operatorType">操作类型</param> private void OnDataSaved(TData entity, DataOperatorType operatorType) { OnDataSaved(operatorType, entity); DataUpdateHandler.OnDataSaved(entity, operatorType); }
/// <summary> /// 保存前处理 /// </summary> /// <param name="entity">保存的对象</param> /// <param name="operatorType">操作类型</param> private void OnPrepareSave(TData entity, DataOperatorType operatorType) { OnPrepareSave(operatorType, entity); DataUpdateHandler.OnPrepareSave(entity, operatorType); }
static MySqlTable() { DataUpdateHandler.InitType <TData>(); }