public string ThoseWhichNotExistInList(Join IJoin, int iCount) { string sFullJoin = ""; Join curJoin = IJoin; while (curJoin != null) { if (!ExistInList(curJoin,iCount)) { sFullJoin = sFullJoin + " INNER JOIN\n" + curJoin.sJoin; } curJoin = curJoin.m_next; } return sFullJoin; }
public void Insert(Join IJoin) { int iCount; int i; iCount = items.Count; if (items.Count == 0) { items.Add(IJoin); return; } for (i = 0; i < iCount; i++) { if (IJoin.NextItemsCount() >= items[i].NextItemsCount()) { items.Insert(i, IJoin); return; } i++; } items.Add(IJoin); }
// Join Join Join Join // m_next->m_next->m_next->..->m_next->null // null<-m_prev<-m_prev<-..<-m_prev<-m_prev private Join CreateInnerJoin(Join pNext) { if (pParentTable != null) { Join IJoin = new Join(); IJoin.tbl = this; IJoin.m_next = pNext; IJoin.sJoin = this.TableName + " ON " + this.pParentTable.TableName + "." + this.TableName + "_ID = " + this.TableName + ".ID"; if (pNext != null) { IJoin.sFullJoin = IJoin.sJoin + " INNER JOIN\n" + pNext.sFullJoin; } else { IJoin.sFullJoin = IJoin.sJoin; } IJoin.m_prev = this.pParentTable.CreateInnerJoin(IJoin); return IJoin; } else { return null; } }
private Join GetTopJoin(Join innerJoin) { if (innerJoin != null) { while (innerJoin.m_prev != null) { innerJoin = innerJoin.m_prev; } return innerJoin; } else { return null; } }
private bool ExistInList(Join IJoin, int iCount) { int j; for (j = 0; j < iCount; j++) { Join xcurJoin = items[j]; while (xcurJoin != null) { if (xcurJoin.sJoin.Equals(IJoin.sJoin)) { // Allready Exist ! return true; } xcurJoin = xcurJoin.m_next; } } return false; }