I am writing a .NET application that enables the extraction of nodes and relationships from Excel spreadsheets so that they can be dynamically generated and loaded into neo4j (see translation / management object model below).
When I load them into neo4j via the neo4jclient I will not know what my nodes look like at run time; they can have any number of attributes and these could have any name and value. In the examples at https://github.com/Readify/Neo4jClient/wiki/cypher-examples it looks like I should have local classes to refer to for attribute names and values; but this will not work. Am I missing a trick here? parameterised queries? (even these examples expected a local, hard coded class).
public class Node
{
public string NodeType = "";
public List<Attribute> Attributes;
public List<Relationship> ParentRelationships;
public List<Relationship> ChildRelationships;
public Node(string nodeType)
{
NodeType = nodeType;
Attributes = new List<Attribute>();
ParentRelationships = new List<Relationship>();
ChildRelationships = new List<Relationship>();
}
public void AddAttribute(Attribute attribute)
{
//We are not allowing empty attributes
if(attribute.GetValue() != "")
this.Attributes.Add(attribute);
}
public string GetIdentifier()
{
foreach (Attribute a in Attributes)
{
if (a.IsIdentifier)
return a.GetValue();
}
return null;
}
public void AddParentRelationship(Relationship pr)
{
ParentRelationships.Add(pr);
}
public void AddChildRelationship(Relationship cr)
{
ChildRelationships.Add(cr);
}
public class Attribute
{
private string Name;
private string Value;
public bool IsIdentifier;
public Attribute(string name, string value, bool isIdentifier)
{
SetName(name);
SetValue(value);
IsIdentifier = isIdentifier;
}
public void SetName(string name)
{
Name = name.Trim();
}
public void SetValue(string value)
{
Value = value.Trim();
}
public string GetName()
{
return Name;
}
public string GetValue()
{
return Value;
}
}