Add() public method

public Add ( string name, InputFragment fragment ) : void
name string
fragment InputFragment
return void
        protected InputFragment VisitInputExpression(DbExpression e, string name, TypeUsage type)
        {
            SqlFragment f = e.Accept(this);

            Debug.Assert(f is InputFragment);

            InputFragment inputFragment = f as InputFragment;

            inputFragment.Name = name;

            if (inputFragment is TableFragment && type != null)
            {
                (inputFragment as TableFragment).Type = type;
            }

            SelectStatement select = inputFragment as SelectStatement;

            if (name != null)
            {
                if (select != null && !select.IsWrapped)
                {
                    scope.Add(name, select.From);
                }
                else
                {
                    scope.Add(name, inputFragment);
                }
            }

            return(inputFragment);
        }
Example #2
0
        protected InputFragment VisitInputExpression(DbExpression e, string name, TypeUsage type)
        {
            SqlFragment f = e.Accept(this);

            Debug.Assert(f is InputFragment);

            InputFragment inputFragment = f as InputFragment;

            inputFragment.Name = name;
            TryFusingSelect(inputFragment);

            if (inputFragment is TableFragment && type != null)
            {
                (inputFragment as TableFragment).Type = type;
            }

            if ((inputFragment is SelectStatement) && ((inputFragment as SelectStatement).From is TableFragment))
            {
                ((inputFragment as SelectStatement).From as TableFragment).Type = type;
            }

            if (name != null)
            {
                scope.Add(name, inputFragment);
            }

            return(inputFragment);
        }
Example #3
0
        public override void Wrap(Scope scope)
        {
            base.Wrap(scope);

            // now we need to add default columns if necessary
            if (Columns.Count == 0)
            {
                AddDefaultColumns(scope);
            }

            // next we need to remove child extents of the select from scope
            if (Name != null)
            {
                scope.Remove(this);
                scope.Add(Name, this);
            }
        }
Example #4
0
        void AddDefaultColumns(Scope scope)
        {
            if (columnHash == null)
            {
                columnHash = new Dictionary <string, ColumnFragment>();
            }

            List <ColumnFragment> columns = GetDefaultColumnsForFragment(From);
            bool Exists = false;

            if (From is TableFragment && scope.GetFragment((From as TableFragment).Table) == null)
            {
                scope.Add((From as TableFragment).Table, From);
                Exists = true;
            }

            foreach (ColumnFragment column in columns)
            {
                // first we need to set the input for this column
                InputFragment input = scope.FindInputFromProperties(column.PropertyFragment);
                column.TableName = input.Name;

                // then we rename the column if necessary
                if (columnHash.ContainsKey(column.ColumnName.ToUpper()))
                {
                    column.ColumnAlias = MakeColumnNameUnique(column.ColumnName);
                    columnHash.Add(column.ColumnAlias, column);
                }
                else
                {
                    columnHash.Add(column.ColumnName.ToUpper(), column);
                }
                Columns.Add(column);
            }
            if (From is TableFragment && Exists)
            {
                scope.Remove((From as TableFragment).Table, From);
            }
        }
    void AddDefaultColumns(Scope scope)
    {
      if (columnHash == null)
        columnHash = new Dictionary<string, ColumnFragment>();

      List<ColumnFragment> columns = GetDefaultColumnsForFragment(From);
      bool Exists = false;
      if (From is TableFragment && scope.GetFragment((From as TableFragment).Table) == null)
      {
        scope.Add((From as TableFragment).Table, From);
        Exists = true;
      }

      foreach (ColumnFragment column in columns)
      {
        // first we need to set the input for this column
        InputFragment input = scope.FindInputFromProperties(column.PropertyFragment);
        column.TableName = input.Name;

        // then we rename the column if necessary
        if (columnHash.ContainsKey(column.ColumnName.ToUpper()))
        {
          column.ColumnAlias = MakeColumnNameUnique(column.ColumnName);
          columnHash.Add(column.ColumnAlias, column);
        }
        else
          columnHash.Add(column.ColumnName.ToUpper(), column);
        Columns.Add(column);
      }
      if (From is TableFragment && Exists)
      {
        scope.Remove(From);
      }
    }
    public override void Wrap(Scope scope)
    {
      base.Wrap(scope);

      // now we need to add default columns if necessary
      if (Columns.Count == 0)
        AddDefaultColumns(scope);

      // next we need to remove child extents of the select from scope
      if (Name != null)
      {
        scope.Remove(this);
        scope.Add(Name, this);
      }
    }