예제 #1
0
파일: Utils.cs 프로젝트: Diogny/CsvDb
 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);
 }
예제 #2
0
        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}");
            }
        }
예제 #3
0
        /// <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));
        }