您好,我想执行以下 Cypher 查询,计算我的指定节点与多少个节点有关系,并nodeName
在此示例中传入。
这是查询:
START n=node:NameIndex(Name = "Mike")
MATCH (n)-->(x)
RETURN n, count(*)
这是我的尝试:
public IEnumerable<VersionNode> GraphNodeCount(string nodeName)
{
GraphQueryLogger.Trace("Now entering GraphNodeCount(string nodeName) Method");
IEnumerable<VersionNode> queryResult = null;
clientConnection = graphOperations.GraphGetConnection();
var query = clientConnection
.Cypher
.Start(new CypherStartBitWithNodeIndexLookup("n", "NameIndex", "Name", nodeName))
.Match("n", "-->", "x")
.Return<VersionNode>("n, count(*)");
queryResult = query.Results.ToList();
return queryResult;
}
这是我的主要方法:
GraphQuery graphQuery = new GraphQuery();
var query = graphQuery.GraphNodeCount("Mike");
foreach (var item in query)
{
Console.WriteLine(item.Name);
}
这是堆栈跟踪:
at System.Threading.Tasks.Task.WaitAll(Task[] tasks, Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.WaitAll(Task[] tasks, Int32 millisecondsTimeout)
at System.Threading.Tasks.Task.WaitAll(Task[] tasks)
at Neo4jClient.GraphClient.Neo4jClient.IRawGraphClient.ExecuteGetCypherResults[TResult](CypherQuery query)
at Neo4jClient.Cypher.CypherFluentQuery`1.get_Results()
at ContentManager_Test.ContentManager_Library.Level_1_API.Graph.Query.GraphQuery.GraphNodeCount(String nodeName)
我得到NullReferenceException was unhandled
对象引用未设置为对象的实例。我错过了什么?