private static int[] GetColumnOrdinals(DataColumn[] dc, TAdoDotNetDataTable TargetTable)
 {
     int[] Result = new int[dc.Length];
     for (int i = 0; i < Result.Length; i++)
     {
         Result[i] = TargetTable.GetColumn(dc[i].ColumnName);
     }
     return(Result);
 }
        public override TRelation GetRelationWith(VirtualDataTable aDetail)
        {
            TAdoDotNetDataTable AdoDetail = aDetail as TAdoDotNetDataTable; //DataRelationships only happen between DataTables.

            if (AdoDetail != null && OriginalTable.ChildRelations != null)
            {
                foreach (DataRelation dr in OriginalTable.ChildRelations)
                {
                    if (dr.ChildTable == AdoDetail.OriginalTable)
                    {
                        return(new TRelation(this, AdoDetail, GetColumnOrdinals(dr.ParentColumns, this), GetColumnOrdinals(dr.ChildColumns, AdoDetail)));
                    }
                }
            }

            return(null);
        }