问题
Im trying to convert a Neo4j Cypher query that works in Neo4j Desktop but when im trying to use it on c# it doesn't work, can someone help me?
C# query:
var type = typeof(T).Name;
var client = Graph.GetClient();
client.Cypher
.Match("(location:Location")
.Where((Location location) => location.GeoNameId == entityGiven.GeoNameId)
.OptionalMatch("()-[r:HAS]->(location)")
.Delete("r")
.With("l")
.Match("admin:" + type + ")")
.Where((Admin admin) => admin.GeoNameId == geoNameId)
.Merge("(admin)-[:HAS]->(location)")
.ExecuteWithoutResults();
Neo4j Cypher Query:
MATCH (l:Location {GeoNameId: 9410021})
OPTIONAL MATCH ()-[r:HAS]->(l)
DELETE r
WITH l
MATCH (a:Admin2 {GeoNameId: 2367567})
MERGE (a)-[:HAS]->(l);
Already got it just missed a little things that's the solution:
.Match("(location:Location)")
.Where((Location location) => location.GeoNameId == entityGiven.GeoNameId)
.OptionalMatch("()-[r:HAS]->(location)")
.Delete("r")
.With("location")
.Match("(admin:" + type + ")")
.Where((Admin admin) => admin.GeoNameId == geoNameId)
.Merge("(admin)-[:HAS]->(location)")
.ExecuteWithoutResults();
来源:https://stackoverflow.com/questions/57394887/convert-neo4j-query-in-c-sharp-using-optinal-match-and-merge