private static void AddExtraRelationships(IDataTableFinder TableFinder, VirtualDataTable aData, TRelationshipList Relations, TBand band, TMasterDetailLinkList MasterDetailLinkList) { foreach (TRelationship tr in Relations) { TDataSourceInfo dParent = TableFinder.TryGetDataTable(tr.ParentTable); if (dParent == null || dParent.Table == null) { FlxMessages.ThrowException(FlxErr.ErrInvalidManualRelationshipDatasetNull, tr.ParentTable); } TDataSourceInfo dChild = TableFinder.TryGetDataTable(tr.ChildTable); if (dChild == null || dChild.Table == null) { FlxMessages.ThrowException(FlxErr.ErrInvalidManualRelationshipDatasetNull, tr.ChildTable); } if (SameTable(dChild.Table, aData) && SameTable(dParent.Table, band.DataSource.Data)) { GetColIndexes(dParent.Table, tr.ParentColumns, true); //we do it here so it checks all columns exist in the parent. They might not exist in our table, and that is ok if our table is a distinct for example) GetColIndexes(dChild.Table, tr.ChildColumns, true); int[] ChildCols = GetColIndexes(aData, tr.ChildColumns, false); int[] ParentCols = GetColIndexes(band.DataSource.Data, tr.ParentColumns, false); if (ChildCols != null && ParentCols != null) { MasterDetailLinkList.AddRelation(band.DataSource.DataState, new TRelation(band.DataSource.Data, aData, ParentCols, ChildCols)); } } } }
public TFlexCelDataSource(string dtName, VirtualDataTable aData, TRelationshipList ExtraRelations, TRelationshipList StaticRelations, TBand MasterBand, string Sort, IDataTableFinder TableFinder) { SplitLink = null; TBand band = MasterBand; TMasterDetailLinkList MasterDetailLinkList = new TMasterDetailLinkList(); while (band != null) { if (band.DataSource != null) { TRelation RelToMaster = band.DataSource.Data.GetRelationWith(aData); if (RelToMaster != null) { MasterDetailLinkList.AddRelation(band.DataSource.DataState, RelToMaster); } //Create the splitlink. TMasterSplitDataTableState SplitMaster = band.DataSource.DataState as TMasterSplitDataTableState; if (SplitMaster != null && String.Equals(SplitMaster.DetailName, dtName, StringComparison.CurrentCultureIgnoreCase)) { if (SplitLink != null) { FlxMessages.ThrowException(FlxErr.ErrSplitNeedsOnlyOneMaster, dtName, SplitMaster.TableName, SplitLink.ParentDataSource.TableName); } SplitLink = new TSplitLink(SplitMaster, SplitMaster.SplitCount); } AddExtraRelationships(TableFinder, aData, ExtraRelations, band, MasterDetailLinkList); AddExtraRelationships(TableFinder, aData, StaticRelations, band, MasterDetailLinkList); } band = band.MasterBand; } MasterDetailLinks = MasterDetailLinkList.ToArray(); Data = aData; DataState = aData.CreateState(Sort, MasterDetailLinks, SplitLink); DataState.FTableName = dtName; FName = dtName; }