SqlAliaser.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

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

                            using System; 
using System.Collections.Generic;
using System.Text;
using System.Data.Linq;
 
namespace System.Data.Linq.SqlClient {
    internal class SqlAliaser { 
        Visitor visitor; 

        internal SqlAliaser() { 
            this.visitor = new Visitor();
        }

        internal SqlNode AssociateColumnsWithAliases(SqlNode node) { 
            return this.visitor.Visit(node);
        } 
 
        class Visitor : SqlVisitor {
            SqlAlias alias; 

            internal Visitor() {
            }
 
            internal override SqlAlias VisitAlias(SqlAlias sqlAlias) {
                SqlAlias save = this.alias; 
                this.alias = sqlAlias; 
                sqlAlias.Node = this.Visit(sqlAlias.Node);
                this.alias = save; 
                return sqlAlias;
            }

            internal override SqlRow VisitRow(SqlRow row) { 
                foreach (SqlColumn c in row.Columns) {
                    c.Alias = alias; 
                } 
                return base.VisitRow(row);
            } 
            internal override SqlTable VisitTable(SqlTable tab) {
                foreach (SqlColumn c in tab.Columns) {
                    c.Alias = alias;
                } 
                return base.VisitTable(tab);
            } 
            internal override SqlExpression VisitTableValuedFunctionCall(SqlTableValuedFunctionCall fc) { 
                foreach (SqlColumn c in fc.Columns) {
                    c.Alias = this.alias; 
                }
                return base.VisitTableValuedFunctionCall(fc);
            }
        } 
    }
} 

// 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