【问题标题】:How to return the object tree from a query from Neo4j Graphenedb to C#如何从 Neo4j Graphenedb 的查询中返回对象树到 C#
【发布时间】:2018-04-07 16:15:15
【问题描述】:

我在 GrapheneDB 上对 Neo4j 进行查询,但它返回匹配的所有组合, 所以我有这棵树:

但是当我查询它时,它会以所有路径的组合列表的形式返回,就像一个组合表(即使在 JSON 视图中):

我需要嵌套的树对象,所以我可以在 UWP 界面上轻松绑定它,例如: Using Cypher to return nested, hierarchical JSON from a tree

我使用了这个命令:

MATCH (p:Pessoa)-[ev:VENDA]-(y)-[e1]-(itemdopedido)-[e2]-(itemdoestoque) 
CALL apoc.convert.toTree(p) yield value
RETURN value;

但我收到此错误:

ERROR Neo.ClientError.Procedure.ProcedureNotFound 没有为此数据库实例注册名称为apoc.convert.toTree 的过程。请确保您已正确拼写过程名称并且已正确部署过程。

在 C# 中,我为顶点和边创建了类:

public class Pedido
{
    public string since { get; set; }
}

public class ItemDoPedido
{
    public double ValorUnitario { get; set; }
}

public class ItemDoEstoque
{
    public string Nome { get; set; }
    public string UnidadeDeMedida { get; set; }
}

public class Pessoa
{
    public string Nome { get; set; }
    //public string Telefone { get; set; }
    public string Facebook { get; set; }
}

然后我尝试使用一些分组:

var results = query.Results.GroupBy(
                    q => new { q.Pessoa, q.Pedido, q.ItemDoPedido, q.ItemDoEstoque }

                )
                .Select(y => new
                {
                    Pessoa = y.Key.Pessoa,
                    Venda = y.Key.Pedido//,                        
                    //Children = y.ToList()
                }
                );
            ;

但我认为它变得复杂了,我更喜欢从服务器查询中准备好对象树。

我该怎么做?

【问题讨论】:

    标签: c# neo4j uwp neo4jclient graphenedb


    【解决方案1】:

    好像找不到程序,可能是因为没有安装APOC。您可以从扩展管理视图将 APOC 添加到 GrapheneDB。更多信息here

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-21
    • 1970-01-01
    • 2020-11-27
    相关资源
    最近更新 更多