public IEnumerable <QueryMapRelationship> GetRelationshipsByRelationshipType(Guid nodeId, params Guid[] relationshipTypes)
        {
            if (DescriptorsByNode.ContainsKey(nodeId))
            {
                Dictionary <Guid, List <QueryMapDescriptor> > descriptorsByType = DescriptorsByNode[nodeId];

                foreach (List <QueryMapDescriptor> descriptorList in descriptorsByType.Values)
                {
                    foreach (QueryMapDescriptor descriptor in descriptorList)
                    {
                        if (Relationships.ContainsKey(descriptor.RelationshipUid.Value))
                        {
                            QueryMapRelationship relationship = Relationships[descriptor.RelationshipUid.Value];

                            foreach (Guid relationshipType in relationshipTypes)
                            {
                                if (relationship.RelationshipTypeUid == relationshipType)
                                {
                                    yield return(relationship);
                                }
                            }
                        }
                    }
                }
            }
        }
        public void FindNodeIdsByRelationshipType(Guid nodeId, ref HashSet <Guid> relatedMapsNodeList, Guid ignoreNodeId, Guid descriptorTypeId, params Guid[] relationshipTypes)
        {
            if (DescriptorsByNode.ContainsKey(nodeId))
            {
                Dictionary <Guid, List <QueryMapDescriptor> > descriptorsByType = DescriptorsByNode[nodeId];

                foreach (List <QueryMapDescriptor> descriptorList in descriptorsByType.Values)
                {
                    foreach (QueryMapDescriptor descriptor in descriptorList)
                    {
                        if (Relationships.ContainsKey(descriptor.RelationshipUid.Value))
                        {
                            QueryMapRelationship relationship = Relationships[descriptor.RelationshipUid.Value];

                            foreach (Guid relationshipType in relationshipTypes)
                            {
                                if (relationship.RelationshipTypeUid == relationshipType)
                                {
                                    var descriptors = DescriptorsByRelationship[relationship.RelationshipUid][descriptorTypeId];

                                    foreach (QueryMapDescriptor opposingDescriptor in descriptors)
                                    {
                                        if (opposingDescriptor.NodeUid.Value != null && (ignoreNodeId == Guid.Empty || opposingDescriptor.NodeUid != ignoreNodeId))
                                        {
                                            relatedMapsNodeList.Add(opposingDescriptor.NodeUid.Value);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        public QueryMapResultSet(IMultipleResults queryMapResultSets)
        {
            var queryMapResultSet = queryMapResultSets.GetResult<QueryMapMultiDepthResult>();

            while (queryMapResultSet != null)
            {
                foreach (var queryMapResult in queryMapResultSet)
                {
                    if (queryMapResult.Level != null)
                    {
                        if (queryMapResult.NodeUid.HasValue && queryMapResult.NodeUid != Guid.Empty)
                        {
                            /// Make sure that we aren't displaying a domain node.
                            if (queryMapResult.NodeTypeUid.HasValue && queryMapResult.NodeTypeUid != new Guid("263754C2-2F31-4D21-B9C4-6509E00A5E94"))
                            {
                                /// The QueryMap procedure returns ALL nodes by following relationships to max depth meaning some nodes are repeated in some of the levels multiple nodes may connect to them.
                                if (!Nodes.ContainsKey(queryMapResult.NodeUid.Value))
                                {
                                    /// TODO: Need to consider if we require the NodeOriginalId.
                                    QueryMapNode node = new QueryMapNode(queryMapResult);

                                    Nodes[queryMapResult.NodeUid.Value] = node;
                                }
                            }
                        }
                    }
                    else if (queryMapResult.MetadataId != null)
                    {
                        if (queryMapResult.MetadataId.HasValue && queryMapResult.MetadataId != Guid.Empty)
                        {
                            QueryMapMetadata metadatum = new QueryMapMetadata(queryMapResult);

                            if (metadatum.NodeUid.HasValue)
                            {
                                if (Nodes.ContainsKey(metadatum.NodeUid.Value))
                                {
                                    Nodes[metadatum.NodeUid.Value].AddMetadata(metadatum);
                                }
                            }

                            Metadata.Add(metadatum);
                        }
                    }
                    else if (queryMapResult.DescriptorUid != null)
                    {
                        if (queryMapResult.DescriptorUid.HasValue && queryMapResult.DescriptorUid != Guid.Empty)
                        {
                            QueryMapDescriptor descriptor = new QueryMapDescriptor(queryMapResult);

                            Descriptors.Add(descriptor);
                            AddDescriptorByNode(descriptor);
                            AddDescriptorByRelationship(descriptor);
                        }
                    }
                    else
                    {
                        if (queryMapResult.RelationshipUid.HasValue && queryMapResult.RelationshipUid != Guid.Empty)
                        {
                            /// TODO: Need to consider if we require the RelationshipOriginalId.
                            QueryMapRelationship relationship = new QueryMapRelationship(queryMapResult);

                            Relationships[relationship.RelationshipUid] = relationship;
                        }
                    }
                }

                queryMapResultSet = queryMapResultSets.GetResult<QueryMapMultiDepthResult>();
            }
        }
        public QueryMapResultSet(IMultipleResults queryMapResultSets)
        {
            var queryMapResultSet = queryMapResultSets.GetResult <QueryMapMultiDepthResult>();

            while (queryMapResultSet != null)
            {
                foreach (var queryMapResult in queryMapResultSet)
                {
                    if (queryMapResult.Level != null)
                    {
                        if (queryMapResult.NodeUid.HasValue && queryMapResult.NodeUid != Guid.Empty)
                        {
                            /// Make sure that we aren't displaying a domain node.
                            if (queryMapResult.NodeTypeUid.HasValue && queryMapResult.NodeTypeUid != new Guid("263754C2-2F31-4D21-B9C4-6509E00A5E94"))
                            {
                                /// The QueryMap procedure returns ALL nodes by following relationships to max depth meaning some nodes are repeated in some of the levels multiple nodes may connect to them.
                                if (!Nodes.ContainsKey(queryMapResult.NodeUid.Value))
                                {
                                    /// TODO: Need to consider if we require the NodeOriginalId.
                                    QueryMapNode node = new QueryMapNode(queryMapResult);

                                    Nodes[queryMapResult.NodeUid.Value] = node;
                                }
                            }
                        }
                    }
                    else if (queryMapResult.MetadataId != null)
                    {
                        if (queryMapResult.MetadataId.HasValue && queryMapResult.MetadataId != Guid.Empty)
                        {
                            QueryMapMetadata metadatum = new QueryMapMetadata(queryMapResult);

                            if (metadatum.NodeUid.HasValue)
                            {
                                if (Nodes.ContainsKey(metadatum.NodeUid.Value))
                                {
                                    Nodes[metadatum.NodeUid.Value].AddMetadata(metadatum);
                                }
                            }

                            Metadata.Add(metadatum);
                        }
                    }
                    else if (queryMapResult.DescriptorUid != null)
                    {
                        if (queryMapResult.DescriptorUid.HasValue && queryMapResult.DescriptorUid != Guid.Empty)
                        {
                            QueryMapDescriptor descriptor = new QueryMapDescriptor(queryMapResult);

                            Descriptors.Add(descriptor);
                            AddDescriptorByNode(descriptor);
                            AddDescriptorByRelationship(descriptor);
                        }
                    }
                    else
                    {
                        if (queryMapResult.RelationshipUid.HasValue && queryMapResult.RelationshipUid != Guid.Empty)
                        {
                            /// TODO: Need to consider if we require the RelationshipOriginalId.
                            QueryMapRelationship relationship = new QueryMapRelationship(queryMapResult);

                            Relationships[relationship.RelationshipUid] = relationship;
                        }
                    }
                }

                queryMapResultSet = queryMapResultSets.GetResult <QueryMapMultiDepthResult>();
            }
        }