/// <summary> /// Returns a collection of nodes whose release date falls before /// </summary> /// <param name="start">The DateTime to use as the lower bound of the search</param> /// <param name="end">The DateTime to use as the upper bound of the search</param> /// <returns>A collection of nodes whose release date is in the specified range</returns> public List <BasicNodeModel> GetNodesBetweenDates(DateTime start, DateTime end) { List <BasicNodeModel> nodeModels = new List <BasicNodeModel>(); using (ISession session = driver.Session()) { // Create a transaction session.ReadTransaction(action => { IStatementResult result = action.Run("MATCH (n) WHERE (n.releaseDate >= $lowerBound AND n.releaseDate <= $upperBound) OR (n.deathDate >= $lowerBound AND n.deathDate <= $upperBound) RETURN n", new Dictionary <string, object> { { "lowerBound", DateValueConverter.ToLongValue(start) }, { "upperBound", DateValueConverter.ToLongValue(end) } }); // Add the nodes foreach (IRecord record in result) { nodeModels.Add(BasicNodeModel.FromINode(record[0].As <INode>())); } }); } return(nodeModels); }
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); }
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); }
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); }