将查询转换为neo4jclient代码

时间:2014-01-23 06:56:14

标签: c# neo4j neo4jclient

我有这个查询

 MATCH (root:Lvl1)-[:HAVE_OTDEL|HAVE_GROUP*0..]->(leaf)  RETURN DISTINCT leaf;

 CypherQuery query =
                new CypherQuery(
                    string.Format("MATCH (root:Lvl1)-[:HAVE_OTDEL|HAVE_GROUP*0..]->(leaf)  RETURN DISTINCT leaf;"), new Dictionary<string, object>(), CypherResultMode.Set);
            var persons = ((IRawGraphClient) client).ExecuteGetCypherResults<treeview>(query).ToList();

treeview.cs

  class treeview
    {
        private string Name { get; set; }
        private string lvl { get; set; }
    }

这返回错误序列化...

1 个答案:

答案 0 :(得分:3)

请不要使用ExecuteGetCypherResults。文档告诉您不要使用它。我告诉过你不要使用它(Convert cypher query to c#)。您不需要使用它。请不要使用它。我不知道你在哪里找到它,但文档显然是错误的。

现在,将查询正确转换为C#是:

client.Cypher
    .Match("(root:Lvl1)-[:HAVE_OTDEL|HAVE_GROUP*0..]->(leaf)")
    .ReturnDistinct(leaf => leaf.As<treeview>())
    .Results

如果这对您不起作用,那么您需要向我们提供更多信息。你说“给我回复错误”但你从未列出那个错误。你为什么不发布它?这可能是让我们帮助你的一条信息。