Search code examples
c#.netneo4jneo4j-driver

How can I return actual data from Neo4j using the .net driver?


The data itself is just names of movies and corresponding nicknames. In the neo4j browser, under code>response, it would return:

{
"keys": [
  "n.name",
  "n.Nickname"
],
"length": 2,
"_fields": [
  "Titanic",
  [
    "Iceburg Movie"
  ]
],
"_fieldLookup": {
  "n.name": 0,
  "n.Nickname": 1
  }
},
{
"keys": [
  "n.name",
  "n.NickName"
],
"length": 2,
"_fields": [
  "Jurrasic Park",
  [
    "Dinosaur Movie"
  ]
],
"_fieldLookup": {
  "n.name": 0,
  "n.Nickname": 1
  }
},
{
"keys": [
  "n.name",
  "n.Nickname"
],
"length": 2,
"_fields": [
  "Fast and Furious",
  [
    "Car Movie",
    "Race Movie",
    "Drag Race Movie"
  ]
],
"_fieldLookup": {
  "n.name": 0,
  "n.Nickname": 1
  }
}

I tested the cypher below in the Neo4j browser and it does exactly what I want it to. The problem is that I can't seem to get that data in my C# app.

        using (ISession session = driver.Session())
        {
            IStatementResult result = session.Run("match (n:movie) " +
                "where ANY(name IN n.Nickname where name contains \"" + Nickname + "\")" +
                "return n.name, n.Nickname");
        }
        return result;

I only really want values and maybe keys but any way I can get any form of the data would be helpful.


Solution

  • In C#, a variable (like result) is not available outside of the code block (surrounded by braces, { }) that it is defined in.