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; int cnt = 0; while (aIndex >= 0 && bIndex >= 0) { if (String.Compare(Properties[aIndex--], prop.Properties[bIndex--], true) != 0) { return(false); } if (++cnt == 2) { break; } } return(true); }
public void PushInput(string inputName) { if (PropertyFragment == null) { PropertyFragment = new PropertyFragment(); } PropertyFragment.PushProperty(inputName); }
public PropertyFragment Clone() { PropertyFragment newPF = new PropertyFragment(); foreach (string prop in Properties) { newPF.Properties.Add(prop); } return(newPF); }
public ColumnFragment GetColumnFromProperties(PropertyFragment properties) { ColumnFragment col = Left.GetColumnFromProperties(properties); if (col == null) { col = Right.GetColumnFromProperties(properties); } return(col); }
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) { if (!string.IsNullOrEmpty(input.Name)) { SelectStatement sf = scope.GetFragment(input.Name) as SelectStatement; if (sf != null) { // Special case: undo alias in case of query fusing for (int i = 0; i < sf.Columns.Count; i++) { ColumnFragment cf = sf.Columns[i]; if (column.ColumnName == cf.ColumnAlias) { column.ColumnName = cf.ColumnName; column.ColumnAlias = cf.ColumnAlias; column.TableName = input.Name; return(column); } } } } 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); }