public void AddAlias(Guid dlId, string parentColumn, string parentNamespace, string childColumn, out ErrorResultTO errors) { errors = new ErrorResultTO(); // TODO : This needs to change so we can track at all levels what the root alias is ;) IDataListCompiler compiler = DataListFactory.CreateDataListCompiler(); Guid masterId = dlId; string masterRs = parentNamespace; string masterCol = parentColumn; Guid searchId = dlId; IBinaryDataListEntry masterEntry = null; int aliasSearchRounds = 0; BinaryDataListAlias binaryDataListAlias = null; while (searchId != Guid.Empty) { ErrorResultTO invokeErrors; var bdl = compiler.FetchBinaryDataList(searchId, out invokeErrors); errors.MergeErrors(invokeErrors); if (bdl != null) { string error; bdl.TryGetEntry(masterRs, out masterEntry, out error); errors.AddError(error); if (masterEntry != null) { var aliases = masterEntry.FetchAlias(); if (aliases.TryGetValue(masterCol, out binaryDataListAlias)) { // we have a hit ;) masterId = binaryDataListAlias.MasterKeyID; searchId = masterId; masterRs = binaryDataListAlias.MasterNamespace; masterCol = binaryDataListAlias.MasterColumn; aliasSearchRounds++; } else { // ensure we copy over the alias entry's keys ;) if (IsEmtpy) { var keyItr = masterEntry.FetchRecordsetIndexes(); _myKeys = new IndexList(keyItr.FetchGaps(), keyItr.MaxIndex(), keyItr.MinIndex()); IsEmtpy = false; } searchId = Guid.Empty; // signal end ;) } } else { if (aliasSearchRounds == 0) { throw new Exception("Missing Entry"); } // we hit the bottom earlier, handle it ;) if (binaryDataListAlias != null) { masterEntry = binaryDataListAlias.MasterEntry; } searchId = Guid.Empty; // signal end ;) } } else { throw new Exception("Missing DataList"); } } // Check MasterKeyID to see if it contains an alias, if so keep bubbling until we at end ;) _keyToAliasMap[childColumn] = new BinaryDataListAlias { MasterKeyID = masterId, ChildKey = GenerateKeyPrefix(Namespace, DataListKey), MasterKey = GenerateKeyPrefix(masterRs, masterId), MasterColumn = masterCol, MasterNamespace = masterRs, MasterEntry = masterEntry }; }