neo4jclient 执行删除功能不起作用

neo4jclient execute delete function not working

我正在使用 https://github.com/Readify/Neo4jClient/wiki/cypher-examples#delete-a-user-and-all-inbound-relationships

中的示例
graphClient.Cypher
    .OptionalMatch("(user:User)<-[r]-()")
    .Where((User user) => user.Id == 123)
    .Delete("r, user")
    .ExecuteWithoutResults();

并根据我的需要对其进行更改

WebApiConfig.GraphClient.Cypher
    .OptionalMatch("(user:User)<-[r]-()")
    .Where((User user) => user.userId == userId)
    .Delete("r, user")
    .ExecuteWithoutResults();

但每次我仍然可以通过

获得用户
 User user1 = WebApiConfig.GraphClient.Cypher
        .Match("(u:User)")
        .Where((User u) => u.userId == userId)
        .Return(u => u.As<User>())
        .Results
        .FirstOrDefault();

我做错了什么?

节点标签是

User

属性标签是

LastName, Name, FirstName, UpdatedTime, Email, facebookId, Picture, userId

图数据库的定义class

public static class WebApiConfig
{
    public static void Register(HttpConfiguration config)
    {
        config.MapHttpAttributeRoutes();

        config.Routes.MapHttpRoute(
           name: "ActionApi",
           routeTemplate: "api/{controller}/{action}/{id}",
           defaults: new { id = RouteParameter.Optional }
        );


        //Use an IoC container and register as a Singleton
        var url = ConfigurationManager.AppSettings["GraphDBUrl"];
        var user = ConfigurationManager.AppSettings["GraphDBUser"];
        var password = ConfigurationManager.AppSettings["GraphDBPassword"];
        var client = new GraphClient(new Uri(url), user, password);
        client.Connect();

        GraphClient = client;
    }

    public static IGraphClient GraphClient { get; private set; }
} 

你试过了吗:

graphClient.Cypher
    .Match("(user:User)")
    .OptionalMatch("(user)-[r]-()")
    .Where((User user) => user.Id == 123)
    .Delete("r, user")
    .ExecuteWithoutResults();

我想您的用户有出站关系,因此不会被删除,因为 'r' 只是入站。

这已经很老了,但这是一个最新的提示:

使用 DetachDelete 方法代替 Delete。然后自动删除关系,无需先搜索。