I’m creating an ecommerce with products having their own fields (Id, Name): This is the object I have in c#
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
}
This is my code to generate a product in C# to neo4j
Console.WriteLine("Generate node: ");
var newProduct = new Product{Id=666, Name="Banana"};
client.Cypher
.Create("(product:Product {newProduct})")
.WithParams(new { newProduct })
.ExecuteWithoutResults();
Supposing a user or I need to add some other attributes, such as price to the product node, the first thing is to add a new Product attribute to the class
..
public int price { get; set; }
..
And then modify the cypher code to add the product with the net attribute/property.
Clearly this is a hardcoded approach, not good for a dynamic db/site.
Since I’ve been used to RDBMS this type of problem could only be solved with EAV and numerous pivots, I was hoping that Nosql (ie Neo4J) could have helped me in dealing with variable attributes fileds without EAV. Code that generates code could be a solution?
- What comes in my mind is using Dynamic code/variable or codeDom, is this the way to go? are there other elegant solutions?
- Please provide some explanations or topic to study.
- NoSql should be schema-less but it’s schema-less application is not so easy am I correct?