本文介绍了将密码查询转换为C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个表:

 User
   Name
   Surname

 Phone
   number
   type_of_number



var myList = ((IRawGraphClient) client).ExecuteGetCypherResults<**i_need_class_to_save_it**>(
                    new CypherQuery("match (a:User)-[r]->(b:Phone) return a,collect(b)", null, CypherResultMode.Set))
                .Select(un => un.Data);

如何创建正确的集合以保存数据?

How create correct collection to save data?

推荐答案

听起来您还没有读 https://github.com/Readify/Neo4jClient/wiki/cypher https://github.com/Readify/Neo4jClient/wiki/cypher-examples .您真的应该从这里开始.它有助于阅读本手册.我不只是为了好玩而写.

It sounds like you haven't read https://github.com/Readify/Neo4jClient/wiki/cypher or https://github.com/Readify/Neo4jClient/wiki/cypher-examples. You really should start there. It helps to read the manual. I don't just write it for fun.

对于您的特定情况,让我们从您的Cypher查询开始:

For your specific scenario, let's start with your Cypher query:

MATCH (a:User)-[r]->(b:Phone)
RETURN a, collect(b)

现在,我们将其转换为流利的Cypher:

Now, we convert that to fluent Cypher:

var results = client.Cypher
    .Match("(a:User)-[r]->(b:Phone)")
    .Return((a, b) => new {
        User = a.As<User>(),
        Phones = b.CollectAs<Phone>()
    })
    .Results;

然后您可以轻松地使用它:

You can then use this rather easily:

foreach (var result in results)
    Console.WriteLine("{0} has {1} phone numbers", result.User.Name, result.Phones.Count());

您将需要与您的节点属性模型相匹配的此类:

You will need classes like these, that match your node property model:

public class User
{
    public string Name { get; set; }
    public string Surname { get; set; }
}

public class Phone
{
    public string number { get; set; }
    public string type_of_number { get; set; }
}

再次去阅读 https://github.com /Readify/Neo4jClient/wiki/cypher https://github.com/Readify/Neo4jClient/wiki/cypher-examples .

这篇关于将密码查询转换为C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 10:26