简体   繁体   English

如何从Neo4j Graphenedb查询返回到C#对象树

[英]How to return the object tree from a query from Neo4j Graphenedb to C#

I doing a query on Neo4j on GrapheneDB, but it returns all combinations of match, so I have this tree: 我在GrapheneDB上对Neo4j进行了查询,但它返回了match的所有组合,所以我有这棵树:

树

But when I query it, it returns as a list of combinations of all paths, like a combinational table (even in the JSON view): 但是,当我查询它时,它返回为所有路径的组合列表,例如组合表(即使在JSON视图中):

表

I need the nested tree objects, so I can bind it easily on UWP interface, something like: Using Cypher to return nested, hierarchical JSON from a tree 我需要嵌套的树对象,因此可以在UWP接口上轻松绑定它,例如: 使用Cypher从树中返回嵌套的分层JSON。

I used this command: 我使用了以下命令:

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

but I get this error: 但是我得到这个错误:

ERROR Neo.ClientError.Procedure.ProcedureNotFound There is no procedure with the name apoc.convert.toTree registered for this database instance. 错误Neo.ClientError.Procedure.ProcedureNotFound没有为此数据库实例注册名称为apoc.convert.toTree过程。 Please ensure you've spelled the procedure name correctly and that the procedure is properly deployed. 请确保您正确拼写了过程名称,并且该过程已正确部署。

On C# I created my Classes for the Vertexes and Edges: 在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; }
}

Then I tried to use some Grouping: 然后,我尝试使用一些分组:

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()
                }
                );
            ;

but I think it is getting complicated, I prefer that the Object tree comes ready from the Server Query. 但是我认为它变得越来越复杂,我更喜欢从服务器查询中准备好对象树。

How can I do this? 我怎样才能做到这一点?

It looks like it can't find the procedure, probably because APOC is not installed. 似乎找不到该过程,可能是因为未安装APOC。 You can add APOC to GrapheneDB from the Extensions management view. 您可以从扩展管理视图将APOC添加到GrapheneDB。 More info here 更多信息在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM