如何在 .net core API 中编写 Cypher 查询

问题描述

我有一个类似的 Cypher 查询

MATCH (n: learningPaths) 
WHERE any(x IN n.modules WHERE x = "any course")
RETURN n

如何在 .net core API 中编写此查询获取结果

以前我有这样的查询

MATCH (n:learningPaths)-[]->(m:modules) 
WHERE m.id = "any course" 
RETURN n;

我在下面用 .net core API 写

var result = (
    await _graphClient.Cypher
          .Match(@"(n:learningPaths)-[]->(m:modules)")
          .Where<modules>(m => m.id == "any course")
          .Return((n)=>  n.As<learningPaths>())
          .ResultsAsync)
          .ToList();

解决方法

你有没有试过只做:

var query = client.Cypher
    .Match("MATCH (n:learningPaths)-->(m:modules)")
    .Where("any(x IN n.modules WHERE x = 'any course')"
    .Return( n => n.As<learningPaths>());