public JoinedTable(Table leftTable, TypeJoinedTable type, Table rigthTable) : base(leftTable.TagMapping, leftTable.TableAlias) { _LeftTable = leftTable; _Type = type; _RigthTable = rigthTable; }
/// <summary> /// Adds the elements of an array to the end of this TableCollection. /// </summary> /// <param name="items"> /// The array whose elements are to be added to the end of this TableCollection. /// </param> public virtual void AddRange(Table[] items) { foreach (Table item in items) { this.List.Add(item); } }
public void Replace(Table oldValue, Table currentValue) { int index = IndexOf(oldValue); if (index != -1) List[index] = currentValue; else List.Add(currentValue); }
public override int IndexOf(Table value) { for(int index = 0; index < List.Count; index++) { if (((Table)List[index]).TableAlias != String.Empty && ((Table)List[index]).TableAlias == value.TableAlias) return index; } return base.IndexOf (value); }
public override bool Contains(Table value) { foreach(Table table in List) { if (table.TableAlias != String.Empty && table.TableAlias == value.TableAlias) return true; } return base.Contains(value); }
private ISQLExpression ProcessAttributesWithLoadAttribute(SelectStatement mainQuery, SelectStatement currentQuery, Table currentTable, EntityMapping entityMap, Table attributeTable, AttributeMapping attributeMapping, string atrbId) { if (_IsFirstAttribute) { _IsFirstAttribute = false; // if current table is a JoinedTable : // from clause = mainQuery INNER JOIN attributeTable if (currentTable is JoinedTable) { JoinedTable lastJoinTable = new JoinedTable(mainQuery, TypeJoinedTable.LeftOuter, attributeTable); lastJoinTable.TableAlias = mainQuery.TableAlias; BinaryLogicExpression onCondition = new BinaryLogicExpression( new Column(entityMap.Ids[0], mainQuery.TableAlias, entityMap.GetIdField(entityMap.Ids[0])), BinaryLogicOperator.Equals, new Column(attributeMapping, attributeTable.TableAlias, atrbId)); if (mainQuery.WhereClause.SearchCondition.Count != 0) { foreach (ILogicExpression expression in mainQuery.WhereClause.SearchCondition) { onCondition = new BinaryLogicExpression(onCondition, BinaryLogicOperator.And, expression); } } lastJoinTable.SearchConditions.Add(new BinaryLogicExpression( new Column(entityMap.Ids[0], mainQuery.TableAlias, entityMap.GetIdField(entityMap.Ids[0])), BinaryLogicOperator.Equals, new Column(entityMap.Ids[0], attributeTable.TableAlias, atrbId))); currentQuery.TableAlias = mainQuery.TableAlias; currentQuery.FromClause.Add(lastJoinTable); tableContext.Push(lastJoinTable); for (int i = 0; i < 2; i++) { Column column = mainQuery.SelectList[i] as Column; if (column != null && column.ColumnName == entityMap.Ids[0].Field && entityMap.Ids[0].Generator.Name == GeneratorMapping.GeneratorType.inherited) { column.Alias = null; currentQuery.SelectList.Add(new Column(column.TagMapping, lastJoinTable.TableAlias, column.ColumnName, entityMap.GetIdFieldAs(entityMap.Ids[0]))); } else { currentQuery.SelectList.Add(mainQuery.SelectList[i]); } } if (entityMap.Ids[0].Generator.Name == GeneratorMapping.GeneratorType.inherited) { for (int i = 2; i < mainQuery.SelectList.Count; i++) { Column column = mainQuery.SelectList[i] as Column; if (column != null) { currentQuery.SelectList.Add(new Column(column.TagMapping, lastJoinTable.TableAlias, column.GetSelectName())); } } } if (attributeMapping.Discriminator != null) { currentQuery.SelectList.Add(new Column(attributeMapping, attributeTable.TableAlias, attributeMapping.Discriminator)); } queryContext.Push(currentQuery); string alias = (attributeMapping.Field != attributeMapping.Name) ? attributeMapping.Name : String.Empty; return new Column(attributeMapping, attributeTable.TableAlias, attributeMapping.Field); } // else // from clause = currentTable INNER JOIN attributeTable else { JoinedTable joinTable = new JoinedTable(currentTable, TypeJoinedTable.LeftOuter, attributeTable); joinTable.SearchConditions.Add(new BinaryLogicExpression( new Column(entityMap.Ids[0], currentTable.TableAlias, entityMap.GetIdField(entityMap.Ids[0])), BinaryLogicOperator.Equals, new Column(attributeMapping, attributeTable.TableAlias, atrbId))); currentQuery.TableAlias = currentTable.TableAlias; currentQuery.FromClause.Add(joinTable); currentQuery.WhereClause.SearchCondition = mainQuery.WhereClause.SearchCondition; foreach (ISQLExpression exp in mainQuery.SelectList) { if (!currentQuery.SelectList.Contains(exp)) currentQuery.SelectList.Add(exp); } tableContext.Push(joinTable); } } else { Table rightTable = ((JoinedTable)currentTable).RigthTable; JoinedTable joinTable = new JoinedTable(rightTable, TypeJoinedTable.LeftOuter, attributeTable); joinTable.SearchConditions.Add(new BinaryLogicExpression( new Column(attributeMapping, rightTable.TableAlias, atrbId), BinaryLogicOperator.Equals, new Column(attributeMapping, attributeTable.TableAlias, atrbId))); ((JoinedTable)currentTable).RigthTable = joinTable; currentQuery.TableAlias = currentTable.TableAlias; currentQuery.FromClause.Add(currentTable); currentQuery.WhereClause.SearchCondition = mainQuery.WhereClause.SearchCondition; tableContext.Push(currentTable); } foreach (ISQLExpression exp in mainQuery.SelectList) { if (!currentQuery.SelectList.Contains(exp)) { currentQuery.SelectList.Add(exp); } } if (attributeMapping.Discriminator != null) { currentQuery.SelectList.Add(new Column(attributeMapping, attributeTable.TableAlias, attributeMapping.Discriminator)); } queryContext.Push(currentQuery); string alias1 = (attributeMapping.Field != attributeMapping.Name) ? attributeMapping.Name : String.Empty; return new Column(attributeMapping, attributeTable.TableAlias, attributeMapping.Field, alias1); }
/// <summary> /// Initializes a new instance of the TableCollection class, containing elements /// copied from an array. /// </summary> /// <param name="items"> /// The array whose elements are to be added to the new TableCollection. /// </param> public TableCollection(Table[] items) { this.AddRange(items); }
/// <summary> /// Removes the first occurrence of a specific Table from this TableCollection. /// </summary> /// <param name="value"> /// The Table value to remove from this TableCollection. /// </param> public virtual void Remove(Table value) { this.List.Remove(value); }
/// <summary> /// Inserts an element into the TableCollection at the specified index /// </summary> /// <param name="index"> /// The index at which the Table is to be inserted. /// </param> /// <param name="value"> /// The Table to insert. /// </param> public virtual void Insert(int index, Table value) { this.List.Insert(index, value); }
/// <summary> /// Return the zero-based index of the first occurrence of a specific value /// in this TableCollection /// </summary> /// <param name="value"> /// The Table value to locate in the TableCollection. /// </param> /// <returns> /// The zero-based index of the first occurrence of the _ELEMENT value if found; /// -1 otherwise. /// </returns> public virtual int IndexOf(Table value) { return this.List.IndexOf(value); }
/// <summary> /// Determines whether a specfic Table value is in this TableCollection. /// </summary> /// <param name="value"> /// The Table value to locate in this TableCollection. /// </param> /// <returns> /// true if value is found in this TableCollection; /// false otherwise. /// </returns> public virtual bool Contains(Table value) { return this.List.Contains(value); }
/// <summary> /// Adds an instance of type Table to the end of this TableCollection. /// </summary> /// <param name="value"> /// The Table to be added to the end of this TableCollection. /// </param> public virtual void Add(Table value) { this.List.Add(value); }