SqlAggregateChecker.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DLinq / Dlinq / SqlClient / Query / SqlAggregateChecker.cs / 1305376 / SqlAggregateChecker.cs

                            using System; 
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Data.Linq;
 
namespace System.Data.Linq.SqlClient {
 
    internal class SqlAggregateChecker { 
        Visitor visitor;
 
        internal SqlAggregateChecker() {
            this.visitor = new Visitor();
        }
 
        internal bool HasAggregates(SqlNode node) {
            visitor.hasAggregates = false; 
            visitor.Visit(node); 
            return visitor.hasAggregates;
        } 

        class Visitor : SqlVisitor {
            internal bool hasAggregates;
 
            internal Visitor() {
            } 
 
            internal override SqlExpression VisitSubSelect(SqlSubSelect ss) {
                return ss; 
            }
            internal override SqlSource VisitSource(SqlSource source) {
                return source;
            } 
            internal override SqlExpression VisitUnaryOperator(SqlUnary uo) {
                switch (uo.NodeType) { 
                    case SqlNodeType.Min: 
                    case SqlNodeType.Max:
                    case SqlNodeType.Avg: 
                    case SqlNodeType.Sum:
                    case SqlNodeType.Count:
                    case SqlNodeType.LongCount:
                        this.hasAggregates = true; 
                        return uo;
                    default: 
                        return base.VisitUnaryOperator(uo); 
                }
            } 
        }
    }
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
using System; 
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Data.Linq;
 
namespace System.Data.Linq.SqlClient {
 
    internal class SqlAggregateChecker { 
        Visitor visitor;
 
        internal SqlAggregateChecker() {
            this.visitor = new Visitor();
        }
 
        internal bool HasAggregates(SqlNode node) {
            visitor.hasAggregates = false; 
            visitor.Visit(node); 
            return visitor.hasAggregates;
        } 

        class Visitor : SqlVisitor {
            internal bool hasAggregates;
 
            internal Visitor() {
            } 
 
            internal override SqlExpression VisitSubSelect(SqlSubSelect ss) {
                return ss; 
            }
            internal override SqlSource VisitSource(SqlSource source) {
                return source;
            } 
            internal override SqlExpression VisitUnaryOperator(SqlUnary uo) {
                switch (uo.NodeType) { 
                    case SqlNodeType.Min: 
                    case SqlNodeType.Max:
                    case SqlNodeType.Avg: 
                    case SqlNodeType.Sum:
                    case SqlNodeType.Count:
                    case SqlNodeType.LongCount:
                        this.hasAggregates = true; 
                        return uo;
                    default: 
                        return base.VisitUnaryOperator(uo); 
                }
            } 
        }
    }
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK