I want to get the effect like using Oracle.
For example,I hava two tables: Student
, Tearcher
. I can get all the column names of the two tables using SQL.
Now, I have two nodes: one with label Student
with Name, age, sex, grade properties, another with label Teacher
and Name, sex, salary properties.
Can I get all the property names with Neo4jClient using Cypher?
Thx Z.Tom
You could use the keys
function, if you want to get the properties by label you could match accordingly with a query like:
MATCH (a:Student) WITH keys(a) as k UNWIND k as x RETURN DISTINCT x
Will return all the existing properties on the nodes labeled as Student
Explanation:
Student
.keys
, then passes them by as arrays WITH
UNWIND
catches the arrays and splits them into single rowsRETURN DISTINCT
returns the property names as rows avoiding duplicatesOn C# using Neo4jClient the code to execute that query would be something like:
client = new GraphClient(new Uri(connString), dbuser, dbpass);
client.Connect();
var results = (Result)client.Cypher.Match("(a:Student)")
.With("keys(a) as k")
.Unwind("k as x")
.ReturnDistinct<Result>("x")
.Results.ToList()
Having a class setup for results like this:
public class Result
{
public string x { get; set; }
}