Beispiel #1
0
        private IEnumerable <IDictionary <string, object> > RunHavingClauses(IEnumerable <IDictionary <string, object> > source)
        {
            var havingClauses = _clauses.OfType <HavingClause>().ToList();

            if (havingClauses.Count == 0)
            {
                return(source);
            }

            var selectClause = _clauses.OfType <SelectClause>().FirstOrDefault();

            List <SimpleReference> selectReferences;

            if (selectClause != null)
            {
                selectReferences = selectClause.Columns.ToList();
            }
            else
            {
                selectReferences = new List <SimpleReference> {
                    new AllColumnsSpecialReference()
                };
            }

            foreach (var clause in havingClauses)
            {
                var criteria = HavingToWhere(clause.Criteria, selectReferences);
                source = new SelectClauseHandler(new SelectClause(selectReferences)).Run(source).ToList();
                source = new WhereClauseHandler(_mainTableName, new WhereClause(criteria)).Run(source);
                source = source.Select(d => d.Where(kvp => !kvp.Key.StartsWith(AutoColumnPrefix)).ToDictionary(kvp => kvp.Key, kvp => kvp.Value));
            }

            return(source);
        }
Beispiel #2
0
 private IEnumerable <IDictionary <string, object> > RunWhereClauses(IEnumerable <IDictionary <string, object> > source)
 {
     foreach (var whereClause in _clauses.OfType <WhereClause>())
     {
         source = new WhereClauseHandler(_mainTableName, whereClause).Run(source);
     }
     return(source);
 }