Question

This is my first time posting here, so I apologize if this is the wrong place/ format/ etc.

I am new to both C# and neo4j and I am having trouble getting the basics right. I have looked around at the neo4jClient Git Wiki and I am still having trouble. I want to write code that simply finds a node and displays some of its information, however I cant seem to get it to work. Visual Studio is not giving me any error messages, the code just does not seem to work as it returns no name values and the counter is still at 0. Here is the code:

using Neo4jClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Neo4jtest
{
    class Program
    {


    static void Main(string[] args)
        {
           Console.WriteLine("Hello World");
           var client = new GraphClient(new Uri("http://localhost:7474/db/data"));
           client.Connect();

           var tomQuery = client.Cypher
               .Match("(tom:Person)")
               .Where((Person tom) => tom.Name == "Tom Cruise")
               .Return(tom => tom.As<Person>());

           var peopleNamedTomCruise = tomQuery.Results;

           int counter = 0;
           foreach (Person value in peopleNamedTomCruise)
           {
               Console.WriteLine(value.Name);
               counter++;
           }

           Console.WriteLine(counter.ToString());   
    }

    public class Person
            {
                public string Name {get; set;}
                public int Born { get; set; }
            }
    }
}

As for the data I am using the sample data from the Neo4j "The Movie Graph" exercise.

Any and all help would be greatly appreciated!

Était-ce utile?

La solution

Property names in Neo4j are case sensitive.

The movies example uses lowercase names like name.

You have followed the C# convention with your POCO and used Name.

This will cause the WHERE clause to return no matches.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top