Exemplo n.º 1
0
        private static void Create(ref SelectList root, ref SelectList last, TableReference tableReference)
        {
            foreach (var cr in tableReference.ColumnReferences)
            {
                // Create new expression
                var nsl = SelectList.Create(cr);

                // If root is uninitialized, initialize now
                if (root == null)
                {
                    root = nsl;
                }

                // Append to list if not the first
                if (last != null)
                {
                    last.Append(nsl);
                }

                last = nsl;
            }

            if (root == null)
            {
                throw new InvalidOperationException();
            }
        }
Exemplo n.º 2
0
        public SelectList SubstituteStars()
        {
            var ce    = FindDescendant <ColumnExpression>();
            var subsl = FindDescendant <SelectList>();

            SelectList sl = null;

            if (ce.ColumnReference.IsStar)
            {
                // Build select list from the column list of
                // the referenced table, then replace current node
                if (ce.TableReference.IsUndefined)
                {
                    sl = SelectList.Create(FindAscendant <QuerySpecification>());
                }
                else
                {
                    sl = SelectList.Create(ce.TableReference);
                }

                if (subsl != null)
                {
                    sl.Append(subsl.SubstituteStars());
                }

                return(sl);
            }
            else
            {
                if (subsl != null)
                {
                    Replace(subsl.SubstituteStars());
                }

                return(this);
            }
        }