我有以下代码来查询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; }
}
调试器中给出了以下null结果:
答案 0 :(得分:0)
您的属性位于UpperCamelCase中,但数据库中的字段是小写的。 Neo4jClient设置属性,您需要使用JsonProperty属性来装饰它们:
[JsonProperty("name")]
public string Name {get:set:}
例如