Trying to make a Cypher request which should create (or merge) files and create a relationship to a given root Folder (which may doesn't exists yet). There is a uniquness constraint on :FILE(fullpath) and :FOLDER(fullpath). The Code I have written looks like this:
async public void createFiles(File[] files, Folder rootFolder)
{
var query = client.Cypher
.Merge("(root:FOLDER {fullpath: {newRoot}.fullpath})")
.Merge("(file:FILE {fullpath : {newFiles}.fullpath})")
.Set("file = {newFiles}")
.CreateUnique("root -[:CONTAINS]->(file)")
.WithParam("newFiles", files)
.WithParam("newRoot", rootFolder)
.ReturnDistinct<int>("0");
await query.ResultsAsync;
}
But it throws an Neo4jClient.NeoException: ThisShouldNotHappenError: Developer: Andres claims that: Need something with properties exception.
I think the Exception is thrown by the second .Merge. Isn't it possible to merge multiple nodes with an array as parameter?
Is it a bug or is it my smelling code?
neo4j 2.1.3
fileshave afullpathproperty? You use(file:FILE {fullpath : {newFiles}.fullpath}), but isn'tnewFilesan array ofFile? I don't know if that is part of the problem or not, just looks odd to me - Charlotte SkardonnewFilesis a array withFile Object(which have afullpathproperty). I thought that the query tooks the.fullpathof eachFileinnewFiles. But if this isn't the case, how to do it than? is there an other way, or is the only possible solution to foreach the c# way through the wholeFile[]and make a merge transaction for every node? - fadanner