/****************************************************************************************************************************/ private void CompareProcess(DicParam db) { if (db.Compare == CompareXEnum.In || db.Compare == CompareXEnum.NotIn) { InProcess(db); } else if (db.Compare == CompareXEnum.Like || db.Compare == CompareXEnum.NotLike) { LikeProcess(db); } else { Spacing(X); if (db.Crud == CrudEnum.Join) { DbSql.Column(db.TbAlias, db.TbCol, X); } else if (DC.IsSingleTableOption()) { DbSql.Column(string.Empty, db.TbCol, X); } Compare(db.Compare, X, DC); DbSql.DbParam(db.Param, X); } }
/****************************************************************************************************************************/ private void LikeStrHandle(DicParam dic) { Spacing(X); var name = dic.Param; var value = dic.ParamInfo.Value.ToString(); if (!value.Contains("%") && !value.Contains("_")) { X.Append("concat"); LeftRoundBracket(X); StringConst(Percent.ToString(), X); Comma(X); DbSql.DbParam(name, X); Comma(X); StringConst(Percent.ToString(), X); RightRoundBracket(X); } else if ((value.Contains("%") || value.Contains("_")) && !value.Contains("/%") && !value.Contains("/_")) { DbSql.DbParam(name, X); } else if (value.Contains("/%") || value.Contains("/_")) { DbSql.DbParam(name, X); Spacing(X); Escape(X); Spacing(X); StringConst(EscapeChar.ToString(), X); } else { throw XConfig.EC.Exception(XConfig.EC._015, $"{dic.Action}-{dic.Option}-{value}"); } }
private void InParams(List <DicParam> dbs) { var i = 0; foreach (var it in dbs) { i++; DbSql.DbParam(it.Param, X); if (i != dbs.Count) { Comma(X); } } }
private void TrimProcess(DicParam db) { Spacing(X); Function(db.Func, X, DC); LeftRoundBracket(X); if (db.Crud == CrudEnum.Join) { DbSql.Column(db.TbAlias, db.TbCol, X); } else if (DC.IsSingleTableOption()) { DbSql.Column(string.Empty, db.TbCol, X); } RightRoundBracket(X); Compare(db.Compare, X, DC); DbSql.DbParam(db.Param, X); }
internal protected void UpdateColumn() { // var list = DC.Parameters.Where(it => it.Action == ActionEnum.Update)?.ToList(); if (list == null || list.Count == 0) { throw XConfig.EC.Exception(XConfig.EC._053, "没有设置任何要更新的字段!"); } // Spacing(X); var i = 0; foreach (var item in list) { i++; if (item.Option == OptionEnum.ChangeAdd || item.Option == OptionEnum.ChangeMinus) { if (i != 1) { CRLF(X); Tab(X); } DbSql.Column(string.Empty, item.TbCol, X); Equal(X); DbSql.Column(string.Empty, item.TbCol, X); Option(item.Option, X, DC); DbSql.DbParam(item.Param, X); } else if (item.Option == OptionEnum.Set) { if (i != 1) { CRLF(X); Tab(X); } DbSql.Column(string.Empty, item.TbCol, X); Option(item.Option, X, DC); DbSql.DbParam(item.Param, X); } else { throw XConfig.EC.Exception(XConfig.EC._009, $"{item.Action}-{item.Option}"); } if (i != list.Count) { Comma(X); } } }