Closed farhadnowzari closed 6 months ago
This could be done like this:
graphContext.Anonymous("Movie", Config).Add
graphContext.Anonymous("Actor", Config).AddRange
graphContext.Anonymous("Movie", Config)
.Match(x => x.Where("Id", "<some-id>")).FirstOrDefault();
graphContext.Anonymous("Actor", Config)
.Match(x => x.Where("Id", "<some-id>"))
.Update();
if we add this Anonymous
method to GraphContext
it will be possible to separate this concept from the standard saves.
In the above solution, the Config
also should be defined. The developer needs to create a NodeConfiguration, but for an anonymous object.
Note: This feature needs to be used with care. It is possible here to inject cypher into the label name. For example:
var label = "Movie { Id: 1, Name: 'Test' }); MATCH(a) detach delete a //";
graphContext.Anonymous(label, Config).Add(movie);
The above now will be translated to:
CREATE(m:Movie { Id: 1, Name: 'Test' }); Match(a) detach delete a // { actual paramters }
now the cypher above, will delete and detach everything in the database.
To solve this issue, it is necessary to add validation on the label.
Is your feature request related to a problem? Please describe. It is not at the moment possible to create a node in neo4j without having a C# object type and there are cases in which it is needed to create a generic node without explicitly knowing the type.
Describe the solution you'd like The library should expose the create and match methods which it uses at the end after translating the objects to nodes
Additional context Some refactorings are needed