Search code examples
c#.netneo4jneo4j-dotnet-driver

Neo4j Driver for .NET Readonly mode not working


I have problem with Neo4j Driver for .NET.
To execute query, i use session with ReadOnly mode and Read transaction, but still i can modify graph via query like: Match (n) where Id(n) = 123 set n.foo = 33 return n;

My code:

using (var session = Driver.Session(AccessMode.Read))
        {
            session.ReadTransaction(tx =>
            {
                try
                {
                    var queryResult = tx.Run(job);
                }
                catch (Exception ex)
                {
                    errorMessage = ex.Message;
                }
            });
        }


Why is possible? How resolve this problem?


Solution

  • The AccessMode.Read define the type of the session, and this is used only when you are on a cluster mode, to perform session's transactions on a replica server and not on a core server.

    It doesn't not tell that your session is a readonly one.

    To have a pure read only access, you need to connect to Neo4j with a read only user.