Exemple #1
0
        public BasicNodeModel GetNodeAndRelationships(Guid id)
        {
            BasicNodeModel node = null;

            using (ISession session = driver.Session())
            {
                session.ReadTransaction(action =>
                {
                    IStatementResult statementResult = action.Run(kMatchNodeAndRelationshipsQuery, new Dictionary <string, object> {
                        { "id", id.ToString() }
                    });
                    // Get the relationships
                    foreach (IRecord record in statementResult)
                    {
                        if (node == null)
                        {
                            node = BasicNodeModel.FromINode(record[0].As <INode>());
                        }
                        node.AddRelationship(record["r"].As <IRelationship>(), record["e"].As <INode>());
                    }
                });
            }

            return(node);
        }
Exemple #2
0
        public BasicNodeModel GetNode(Guid id)
        {
            INode result;

            using (ISession session = driver.Session())
            {
                result = session.ReadTransaction(action =>
                {
                    IStatementResult statementResult = action.Run(kMatchNodeQuery, new Dictionary <string, object> {
                        { "id", id.ToString() }
                    });
                    return(statementResult.FirstOrDefault()?[0].As <INode>());
                });
            }

            return(result != null?BasicNodeModel.FromINode(result) : null);
        }
Exemple #3
0
        public BasicNodeModel GetNode(string commonName)
        {
            if (commonName == null)
            {
                return(null);
            }

            INode result = null;

            using (ISession session = driver.Session())
            {
                result = session.ReadTransaction(action =>
                {
                    IStatementResult statementResult = action.Run(kMatchNodeByNameQuery, new Dictionary <string, object> {
                        { "name", commonName }
                    });
                    return(statementResult.FirstOrDefault()?[0].As <INode>());
                });
            }

            return(result != null?BasicNodeModel.FromINode(result) : null);
        }