Query Neo4J to return JSON data using the C# Driver

Good morning everyone,
I am developing my application in C# using the DevExpress XAF. In my application I have a series of custom views and I am starting to experiment with fetching data from my Neo4J DB and bind it to the XAF controller. To do this I am using the C# driver and running a cypher query that returns a list of JSON Objects:

MATCH (e:Environment)<-[:ENV]-(n:Component)-[APP]->(p:Application)
RETURN {objId: n.objId, objName: n.name,projName: p.name,projDesc: p.description,envName: e.name,envDesc: e.description} as obj

When I run the IDriver.Session().Run() I get a list of the JSON objects, I would rather though get a JSON array with my JSON objects so that I could bind that to the controller after deserializing it. I could iterate through the list that I do get from the Run method and build my JSON string but I wanted to know if there is a way to get the data directly formatted as an array.

Thanks,
Gustavo.

I did the iteration through the results to build one unique string but it is extremely slow.

you can turn it into an array with the collect aggration function

MATCH (e:Environment)<-[:ENV]-(n:Component)-[APP]->(p:Application)
WITH {objId: n.objId, objName: n.name,projName: p.name,projDesc: p.description,envName: e.name,envDesc: e.description} as obj
RETURN collect(obj) as objects
2 Likes

Thank you Michael, that was exactly what I was looking for!