public ColumnFragment GetColumnFromProperties(PropertyFragment properties)
 {
     ColumnFragment col = Left.GetColumnFromProperties(properties);
     if (col == null)
         col = Right.GetColumnFromProperties(properties);
     return col;
 }
        public override SqlFragment Visit(DbVariableReferenceExpression expression)
        {
            PropertyFragment fragment = new PropertyFragment();

            fragment.Properties.Add(expression.VariableName);
            return(fragment);
        }
 public void PushInput(string inputName)
 {
     if (PropertyFragment == null)
     {
         PropertyFragment = new PropertyFragment();
     }
     PropertyFragment.PushProperty(inputName);
 }
        public ColumnFragment GetColumnFromProperties(PropertyFragment properties)
        {
            ColumnFragment col = Left.GetColumnFromProperties(properties);

            if (col == null)
            {
                col = Right.GetColumnFromProperties(properties);
            }
            return(col);
        }
        public PropertyFragment Clone()
        {
            PropertyFragment newPF = new PropertyFragment();

            foreach (string prop in Properties)
            {
                newPF.Properties.Add(prop);
            }
            return(newPF);
        }
        public override SqlFragment Visit(DbPropertyExpression expression)
        {
            propertyLevel++;
            PropertyFragment fragment = expression.Instance.Accept(this) as PropertyFragment;

            fragment.Properties.Add(expression.Property.Name);
            propertyLevel--;

            // if we are not at the top level property then just return
            if (propertyLevel > 0)
            {
                return(fragment);
            }

            ColumnFragment column = new ColumnFragment(null, fragment.LastProperty);

            column.PropertyFragment = fragment;
            InputFragment input = scope.FindInputFromProperties(fragment);

            if (input != null)
            {
                column.TableName = input.Name;
            }

            // now we need to check if our column name was possibly renamed
            if (input is TableFragment)
            {
                return(column);
            }

            SelectStatement select = input as SelectStatement;
            UnionFragment   union  = input as UnionFragment;

            if (select != null)
            {
                select.HasDifferentNameForColumn(column);
            }
            else if (union != null)
            {
                union.HasDifferentNameForColumn(column);
            }

            // input is a table, selectstatement, or unionstatement
            return(column);
        }
        public override bool Equals(object obj)
        {
            if (!(obj is PropertyFragment))
            {
                return(false);
            }
            PropertyFragment prop = obj as PropertyFragment;

            Debug.Assert(Properties != null && prop.Properties != null);

            int aIndex = Properties.Count - 1;
            int bIndex = prop.Properties.Count - 1;

            while (aIndex >= 0 && bIndex >= 0)
            {
                if (String.Compare(Properties[aIndex--], prop.Properties[bIndex--], true) != 0)
                {
                    return(false);
                }
            }
            return(true);
        }
 public PropertyFragment Clone()
 {
     PropertyFragment newPF = new PropertyFragment();
     foreach (string prop in Properties)
         newPF.Properties.Add(prop);
     return newPF;
 }
 public void PushInput(string inputName)
 {
     if (PropertyFragment == null)
         PropertyFragment = new PropertyFragment();
     PropertyFragment.PushProperty(inputName);
 }