using System; using System.Collections.Generic; using System.Linq; using System.Text; using SqlLinq.SyntaxTree.Aggregates; namespace SqlLinq.SyntaxTree { [SyntaxNode(RuleConstants.RULE_COLUMNS_TIMES)] [SyntaxNode(RuleConstants.RULE_COLUMNS)] public class Columns : NonTerminalNode { public Columns() { } public bool AllColumns { get { return Rule.Index == (int)RuleConstants.RULE_COLUMNS_TIMES || CountAll; } } public bool CountAll { get { return FindDescendants<CountAllNode>().Count() != 0; } } public bool Distinct { get { return FindChild<NonTerminalNode>(RuleConstants.RULE_RESTRICTION_DISTINCT) != null; } } public IEnumerable<string> GetFieldList() { // first get all the fields being specifically returned // depending on how the slect statement is contructed the parser may or may not elimate some intermediate reductions // the where statement here will elimate those instances where reductions are not elimated by the parser return (from c in ColumnSources from f in c.GetFields() select f).ToList().ConvertAll<string>(field => field.SourceId).Distinct(StringComparer.CurrentCultureIgnoreCase); } public bool IncludeInResultSet(string id) { return ColumnSources.Where(source => source.SourceId == id && source is AggregateNode == false).Count() > 0; } public IEnumerable<ColumnSource> ColumnSources { get { return FindDescendants<ColumnSource>().Where(item => item.FindChild<ColumnSource>() == null); } } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
10 PRINT "Don is cool" 20 GOTO 10