circles-arrows / blueprint41

An Object Graph Mapper for CSharp to connect to Neo4j or Memgraph.
http://www.blueprint41.com/
MIT License
31 stars 8 forks source link

Is there a way to write custom neo4j code or execute stored procs using blueprint41? #6

Closed hewhofreeks closed 4 years ago

hewhofreeks commented 4 years ago

So far most of the functionality I've needed from an ORM seems to be available in blueprint41 but there are times when certain methods aren't available (or not easily found in the documentation).

Off the top of my head I can't figure out ways to do UNWINDs or WHERE NOT in a relationship ex: MATCH (p:person) WHERE NOT (p)-[:executes]-(:transaction) RETURN p

We've been able to manage by finding alternative ways to approach these problems but there are some times when just writing some neo4j would be easier. Is there a way to access the bolt driver itself for times when I have to do this? Are there any plans for updates that allow stored procedures to be added into the datastore?

circles-arrows commented 4 years ago

The good news is that the next release of Blueprint41 will support "Unwind" and many other missing functionalities for type-safe queries. It will also support Neo4j 4.x and Bolt Driver 4.x. The code is nearing completion, but we still need to do some testing and write the updated documentation. For now you can use the Run functionality to execute cypher directly, but when the next Blueprint41 is released it's better to upgrade the code to have type-safe queries so you benefit from compile-time errors on incompatible code after you upgrade the datastore.

To execute Cypher directly, in Blueprint v1.0.17 you can use the method:

using (Transaction trans = Transaction.Begin())
{
    IStatementResult result = Neo4jTransaction.Run("MATCH (p:person) WHERE NOT (p)-[:executes]-(:transaction) RETURN p");
}

Neo4jTransaction resides in namespace: Blueprint41.Neo4j.Persistence.

In the next version of Blueprint41 this method is slightly changed, and becomes an instance method on the Transaction object.

using (Transaction trans = Transaction.Begin())
{
    RawResult result = trans.Run("MATCH (p:person) WHERE NOT (p)-[:executes]-(:transaction) RETURN p");
}

It returns a "RawResult" object that is a wrapper around the IStatementResult (for Bolt Driver v1.7.2) or IResult (for Bolt Driver v4.x).

hewhofreeks commented 4 years ago

Awesome! This all looks great and sounds very promising. Thank you for your prompt response.