Inheritance: SqlFragment
        public void Remove(InputFragment fragment)
        {
            if (fragment == null) return;
            if (fragment.Name != null)
                scopeTable.Remove(fragment.Name);

            if (fragment is SelectStatement)
                Remove((fragment as SelectStatement).From);
            else if (fragment is JoinFragment)
            {
                JoinFragment j = fragment as JoinFragment;
                Remove(j.Left);
                Remove(j.Right);
            }
            else if (fragment is UnionFragment)
            {
                UnionFragment u = fragment as UnionFragment;
                Remove(u.Left);
                Remove(u.Right);
            }
        }
 private void WrapJoinInputIfNecessary(InputFragment fragment, bool isRightPart)
 {
     if (fragment is SelectStatement ||
         fragment is UnionFragment)
         fragment.Wrap(scope);
     else if (fragment is JoinFragment && isRightPart)
         fragment.Wrap(null);
 }
    List<ColumnFragment> GetDefaultColumnsForFragment(InputFragment input)
    {
      List<ColumnFragment> columns = new List<ColumnFragment>();

      if (input is TableFragment)
      {
        return GetDefaultColumnsForTable(input as TableFragment);
      }
      else if (input is JoinFragment || input is UnionFragment)
      {
        Debug.Assert(input.Left != null);
        columns = GetDefaultColumnsForFragment(input.Left);
        if (input is JoinFragment && input.Right != null)
        {
          List<ColumnFragment> right = GetDefaultColumnsForFragment(input.Right);
          columns.AddRange(right);
        }
      }
      else if (input is SelectStatement)
      {
        SelectStatement select = input as SelectStatement;
        foreach (ColumnFragment cf in select.Columns)
        {
          ColumnFragment newColumn = new ColumnFragment(cf.TableName,
              string.IsNullOrEmpty(cf.ColumnAlias) ? cf.ActualColumnName : cf.ColumnAlias
              );
          newColumn.PushInput(cf.ActualColumnName);
          if (cf.TableName != null && cf.ColumnAlias == null)
            newColumn.PushInput(cf.TableName);
          if (select.Name != null)
          {
            newColumn.PushInput(select.Name);      // add the scope 
          }
          columns.Add(newColumn);
        }
        return columns;
      }
      else
        throw new NotImplementedException();
      if (!String.IsNullOrEmpty(input.Name) && input.Name != From.Name)
        foreach (ColumnFragment c in columns)
        {
            c.PushInput(input.Name);
        }
      return columns;
    }
 private InputFragment WrapJoinInputIfNecessary(InputFragment fragment, bool isRightPart)
 {
   if (fragment is SelectStatement || fragment is UnionFragment)
   {
     fragment.Wrap(scope);
     fragment.Scoped = true;
   }
   else if (fragment is JoinFragment && isRightPart)
   {
     SelectStatement select = new SelectStatement();
     select.From = fragment;
     select.Name = fragment.Name;
     select.Wrap(scope);
     return select;
   }
   return fragment;
 }
 void AddDefaultColumnsForFragment(InputFragment input)
 {
     if (input is TableFragment)
     {
         AddDefaultColumnsForTable(input as TableFragment);
     }
     else if (input is JoinFragment)
     {
         JoinFragment j = input as JoinFragment;
         AddDefaultColumnsForFragment(j.Left);
         AddDefaultColumnsForFragment(j.Right);
     }
     else
         throw new NotImplementedException();
 }
 public void Add(string name, InputFragment fragment)
 {
     scopeTable.Add(name, fragment);
 }
Exemple #7
0
 public void Remove(InputFragment fragment)
 {
   if( fragment == null ) return;
   Remove(fragment.Name, fragment);
 }