public static bool TrySplitColumnConstant(this ExpressionOperator expression, out DbQuery.ColumnOperand column, out DbQuery.ConstantOperand constant) { column = null; constant = null; if (expression == null) { return(false); } //try first with left if ((column = expression.Left as DbQuery.ColumnOperand) == null) { if ((column = expression.Right as DbQuery.ColumnOperand) != null) { constant = expression.Left as DbQuery.ConstantOperand; } } else { constant = expression.Right as DbQuery.ConstantOperand; } return(column != null && constant != null); }
internal DbQueryExpressionExecuter(DbQueryHandler handler, DbQuery.ColumnOperand columnOperand, TokenType oper, DbQuery.ConstantOperand constantOperand) { if (columnOperand == null || !(Operator = oper).IsComparison() || constantOperand == null || (Handler = handler) == null) { throw new ArgumentException($"cannot execute comparison expression"); } //get the table column handler Column = handler.Database.Index(columnOperand.Column.Hash); // . handler.WhereColumns[columnOperand.Column.Hash]; //get the constant value to compare Constant = constantOperand.Evaluate(null); Reader = Handler.TableReaders.FirstOrDefault(r => r.Table == Column.Table); if (Reader == null) { throw new ArgumentException($"could not resolve data table reader for column: {Column}"); } }
/// <summary> /// call generic class /// </summary> /// <typeparam name="T"></typeparam> /// <param name="handler"></param> /// <param name="columnOperand"></param> /// <param name="oper"></param> /// <param name="constantOperand"></param> /// <returns></returns> IEnumerable <int> ExecuteColumnExpression <T>(DbQueryHandler handler, DbQuery.ColumnOperand columnOperand, TokenType oper, DbQuery.ConstantOperand constantOperand) where T : IComparable <T> { var executer = new DbQueryExpressionExecuter <T>(handler, columnOperand, oper, constantOperand); return(executer.Execute().SelectMany(pair => pair.Value)); }