string StringLikeFull(string field, ExpressionType nodeType, ref int parIndex, AddParameHandler addParame, string likeFormat,object args) { string parName = string.Format("@like{0}" , parIndex); parIndex += 1; if (!args.ToString().Contains("%")) { args = string.Format(likeFormat, args); } addParame(parName, args); if (nodeType == ExpressionType.Equal) { return dBAdapter.StringLikeFormat(field, parName); } else { return dBAdapter.StringNotLikeFormat(field, parName); } //return string.Format("{0} LIKE {1}", field, parName); }
public string StringLikeRight(string field, ExpressionType nodeType, ref int parIndex, AddParameHandler addParame, object[] args) { string str = args[0].ToString(); str = str.Replace("%",""); return StringLikeFull(field, nodeType, ref parIndex, addParame, "{0}%", str); }
public string StartsWith(string field, ExpressionType nodeType, ref int parIndex, AddParameHandler addParame, object[] args) { var par = args[0].ToString(); string parName = string.Format("@StartsWith{0}", parIndex); parIndex += 1; addParame(parName, par); var str = dBAdapter.SubstringFormat(field, 0, par.Length); if (nodeType == ExpressionType.Equal) { return string.Format("{0}={1}", str, parName); } else { return string.Format("{0}!={1}", str, parName); } }
public string Substring(string field, ExpressionType nodeType, ref int parIndex, AddParameHandler addParame, object[] args) { return dBAdapter.SubstringFormat(field, (int)args[0], (int)args[1]); //return string.Format(" SUBSTRING({0},{1},{2})", field, args[0], args[1]); }
public string In(string field, ExpressionType nodeType, ref int parIndex, AddParameHandler addParame, object[] args) { string str = InFormat(args[0], ref parIndex, addParame); if (nodeType == ExpressionType.Equal) { return dBAdapter.InFormat(field, str); } else { return dBAdapter.NotInFormat(field, str); } //return string.Format("{0} IN ({1})", field, str); }
public string Equals(string field, ExpressionType nodeType, ref int parIndex, AddParameHandler addParame, object[] args) { string parName = string.Format("@equalEnum{0}", parIndex); parIndex += 1; var obj = args[0]; obj = ObjectConvert.ConvertObject(obj.GetType(), obj); addParame(parName, obj); if (nodeType == ExpressionType.Equal) { return string.Format("{0}={1}", field, parName); } else { return string.Format("{0}!={1}", field, parName); } }
string InFormat(object value, ref int parIndex, AddParameHandler addParame) { string str = ""; var par2 = value; if (par2 is string) { string parName = string.Format("@in{0}", parIndex); addParame(parName, value); str = parName; } else if (par2 is string[]) { IEnumerable list = par2 as IEnumerable; foreach (var s in list) { string parName = string.Format("@in{0}", parIndex); addParame(parName, s); parIndex += 1; str += string.Format("{0},", parName); } if (str.Length > 1) { str = str.Substring(0, str.Length - 1); } } else//按数字 { IEnumerable list = par2 as IEnumerable; foreach (var s in list) { string parName = string.Format("@in{0}", parIndex); addParame(parName, (int)s); parIndex += 1; str += string.Format("{0},", parName); } if (str.Length > 1) { str = str.Substring(0, str.Length - 1); } } return str; }
public string AVG(string field, ExpressionType nodeType, ref int parIndex, AddParameHandler addParame, object[] args) { return string.Format("avg({0})", field); }
public string DateTimeDateDiff(string field, ExpressionType nodeType, ref int parIndex, AddParameHandler addParame, object[] args) { string parName = string.Format("@DateDiff{0}", parIndex); addParame(parName, args[1]); parIndex += 1; //DateDiff(2015/2/5 17:59:44,t1.AddTime,@DateDiff1)>1 return dBAdapter.DateDiffFormat(field, args[0].ToString(), parName); //return string.Format("DateDiff({0},{1},{2}){3}", args[0], field, parName, args[2]); }
public string Between(string field, ExpressionType nodeType, ref int parIndex, AddParameHandler addParame, object[] args) { string parName = string.Format("@between{0}", parIndex); addParame(parName, args[0]); parIndex += 1; string parName2 = string.Format("@between{0}", parIndex); addParame(parName2, args[1]); parIndex += 1; if (nodeType == ExpressionType.Equal) { return dBAdapter.BetweenFormat(field, parName, parName2); } else { return dBAdapter.NotBetweenFormat(field, parName, parName2); } //return string.Format("{0} between {1} and {2}", field, parName, parName2); }
public string StringContains(string field, ExpressionType nodeType, ref int parIndex, AddParameHandler addParame, object[] args) { string parName = string.Format("@contrains{0}", parIndex); addParame(parName, args[0]); parIndex += 1; if (nodeType == ExpressionType.Equal) { return dBAdapter.StringContainsFormat(field, parName); } else { return dBAdapter.StringNotContainsFormat(field, parName); } //return string.Format("CHARINDEX({1},{0})>0", field, parName); }