In using Neo4j I'm able to create an array of nodes with labels and then create relationships between those nodes. The labels are essentially mappings to my POCOs (the Dog label relates to a Dog POCO in C#) and these POCOs implement from a simple base POCO containing only an ID property.
When I know the type/label of the node to retrieve, I'm able to cast it using the node.As < T > syntax within the return statement. However, when doing things such as traversing a path between nodes, I will not know the type of the node that I am traversing. While it is technically possible to cast the node as the base type that my POCOs implement from, I lose all of the properties that are specific to the the super class.
Any ideas on how to get started with this one?
You could (depending on how you feel about it) try using dynamic, for example, you can set it up like so:
and retrieve with:
Obviously in this case I would know the types I was returning. Now, you'll notice I'm using
Node<string>
in this - which generally is frowned upon - the reason I'm using it is that it strips out all the normal stuff neo4j returns back, and separates theData
out - which is really all I'm interested in.You might be tempted to try doing:
but the problem you'll end up with here is that the Neo4jClient doesn't deal with dynamic and will actually return it as an
object
which loses all your properties.This should at least give you a starting point, if you need help with a specific type of query it'd be worth putting the query up for reference.