/// <summary> /// Pass command? /// </summary> /// <param name="command">Command.</param> /// <param name="table">Table.</param> /// <param name="row">Row.</param> /// <param name="from">Use state FROM keyword.</param> public static bool Pass(string command, MochaTableResult table, MochaRow row, bool from) { string[] parts = Mhql_LEXER.SplitFunctionParameters(command); if (parts.Length != 3) { throw new ArgumentOutOfRangeException("The BETWEEN function can only take 3 parameters!"); } int dex = Mhql_GRAMMAR.GetIndexOfColumn(parts[0], table.Columns, from); decimal range1, range2, value; if (!decimal.TryParse(parts[1].Trim(), out range1) || !decimal.TryParse(parts[2].Trim(), out range2) || !decimal.TryParse(row.Datas[dex].Data.ToString(), out value)) { throw new ArithmeticException("The parameter of the BETWEEN command was not a number!"); } return (range1 <= range2 ? range1 <= value && value <= range2 : range2 <= value && value <= range1); }
/// <summary> /// Pass command? /// </summary> /// <param name="command">Command.</param> /// <param name="table">Table.</param> /// <param name="row">Row.</param> /// <param name="from">Use state FROM keyword.</param> public static bool Pass(string command, MochaTableResult table, MochaRow row, bool from) { string[] parts = Mhql_LEXER.SplitFunctionParameters(command); int dex = Mhql_GRAMMAR.GetIndexOfColumn(parts[0], table.Columns, from); for (int index = 1; index < parts.Length; ++index) { if (row.Datas[dex].Data.ToString().StartsWith(parts[index])) { return(true); } } return(false); }