簡體   English   中英

C#Neo4J查詢未返回節點屬性

[英]C# Neo4J Query not Returning Node Properties

我有以下代碼來查詢Neo4J圖。 但是,即使返回了所有節點,它們的屬性在內部類中也被設置為null。

// Method to retrieve the passed functional family from the graph database
public void FromGraph(string funFam)
{
    // Create a new client and connect to the database
    var client = new GraphClient(new Uri("http://localhost:7474/db/data"), this.dbUsername, this.dbPassword);
    client.Connect();

    // Run the query
    var queryResults = client.Cypher
        .Match("(a:FunFam {name: '" + funFam + "'})-[*]-(b)")
        .Return((a, b) => new
        {
            a = a.As<F>(),
            b = b.As<K>()
        })
        .Results;
    Console.WriteLine(queryResults);


    Console.ReadLine();
}

// An internal class used to hold the FunFam node from the graph database
internal class F
{
    // Private properties
    private string consensus;
    private string name;

    // getters and setters
    public string Consensus { get => consensus; set => consensus = value; }
    public string Name { get => name; set => name = value; }
}

// An internal class used to hold the Kmer node from the graph database
internal class K
{
    // Private properties
    private string sequence;
    private List<string> offsetAt0;
    private List<string> offsetAt1;
    private List<string> offsetAt2;

    // Getters and setters
    public string Sequence { get => sequence; set => sequence = value; }
    public List<string> OffsetAt0 { get => offsetAt0; set => offsetAt0 = value; }
    public List<string> OffsetAt1 { get => offsetAt1; set => offsetAt1 = value; }
    public List<string> OffsetAt2 { get => offsetAt2; set => offsetAt2 = value; }
}

在調試器中給出以下空結果:

調試器映像

您的屬性在UpperCamelCase中,但是數據庫中的字段為小寫。 Neo4jClient設置屬性,您需要使用JsonProperty屬性裝飾它們:

[JsonProperty("name")] 
public string Name {get:set:}

例如

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM