Sometimes when doing Cypher queries the result is only one column and not multiple columns, therefore it makes sense to have a method in the fluent API to let this be known, so we do not have to map the column to an object type.
So fluent support to deserialize common result sets where cypher returns a result with only 1 column with the help of Tatham Oddie is completed.
So in the Neo4jClient you can do this, when the result from Cypher is one column via REST:
var result = agencySource .StartCypher("a1") .AddStartPoint("a2", agency.Reference) .Match("p = allShortestPaths( a1-[*..20]-a2 )") .Return<PathsResult>("p") .ResultSet;
So, if you need cypher results with only one column then use .ResultSet instead of .Results, thus no need for expression tree column matches to assist the deserializer with multiple column names.
Here is a sample rest response with 1 column result that is suited perfectly for ResultSet.
{ "data" : [ [ { "start" : "http://localhost:20001/db/data/node/215", "nodes" : [ "http://localhost:20001/db/data/node/215", "http://localhost:20001/db/data/node/0", "http://localhost:20001/db/data/node/219" ], "length" : 2, "relationships" : [ "http://localhost:20001/db/data/relationship/247", "http://localhost:20001/db/data/relationship/257" ], "end" : "http://localhost:20001/db/data/node/219" } ], [ { "start" : "http://localhost:20001/db/data/node/215", "nodes" : [ "http://localhost:20001/db/data/node/215", "http://localhost:20001/db/data/node/1", "http://localhost:20001/db/data/node/219" ], "length" : 2, "relationships" : [ "http://localhost:20001/db/data/relationship/248", "http://localhost:20001/db/data/relationship/258" ], "end" : "http://localhost:20001/db/data/node/219" } ] ], "columns" : [ "p" ] }
If you wondering what the hell is agencySource, it is just node references, that I got using gremlin, which can spin off cypher queries, cool is it not?
var agencies = graphClient .RootNode .Out<Agency>(Hosts.TypeKey) .ToList();
This just enumerate through the list of nodes to run your cypher queries off the node directly! Have these imports declarations:
using Neo4jClient.ApiModels.Cypher;
using Neo4jClient.Gremlin;
using Neo4jClient.Cypher;
Summary
Use .ResultSet for single column result sets and use .Results when dealing with multiple column results.
Oh my goodness! Impressive article dude! Thank you so much, However I am having issues with
your RSS. I don’t understand why I can’t subscribe to it.
Is there anybody getting similar RSS issues? Anyone that knows the answer can you kindly respond?
Thanks!!