Reputation: 343
I am using the Neo4j.Driver in C# to query a Neo4J database. My cypher query returns multiple nodes that don't have the same label, lets say i return both movies and actors. I have a C# Movie and a C# Actor class. In order to instantiate the proper C# class (either movie or actor) and set the properties based on the returned records, how do i find out what label(s) a returned node has?
var cursor = await transaction.RunAsync(cypher.ToString());
await cursor.ForEachAsync(record =>
{
var movie = new Movie();
movie.Name = record["name"].As<string>();
....
}
Upvotes: 0
Views: 894
Reputation: 7478
On a Node
object you should find the Labels
property, @see https://github.com/neo4j/neo4j-dotnet-driver/blob/7d954b4d86d134b360a8889ff14a2b6b1a339d7f/Neo4j.Driver/Neo4j.Driver/Types/INode.cs#L31
As an example :
var cursor = await transaction.RunAsync(cypher.ToString());
await cursor.ForEachAsync(record =>
{
var movie = new Movie();
movieNode = record["movie"].As<INode>();
movieNode.Labels[0]
....
}
Upvotes: 1