Search code examples
c#neo4jneo4jclient

How to create a labelled a node through C# in Neo4j


I am new to Neo4j and using Neo4j client to connect to the server through my C# application.

I have written following code to create a node in C#.

 public  class Author
    {
        public string Gender { get; set; }
        public string Title { get; set; }
        public string FirstName { get; set; }
        public string MiddleInitial { get; set; }
        public string Surname { get; set; }
    }

In main() method:

client.Connect();

foreach (var item in AuthorList)
{
   client.Create(new GraphClasses.Author { FirstName = item.FirstName, Gender = item.Gender, MiddleInitial = item.MiddleInitial, Surname = item.Surname, Title = item.Title });
}

In above code AuthorList is the list of Authors. This code works and creates author nodes in the Neo4j DB. However I wish to label the nodes as "AUTHOR" which is not implicitly done.

How do I achieve this?


Solution

  • This exact scenario is described in the documentation: https://github.com/Readify/Neo4jClient/wiki/cypher-examples#create-a-user

    I'd encourage you to read that page, as well as https://github.com/Readify/Neo4jClient/wiki/cypher