Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transactions and WithDatabase #367

Merged
merged 3 commits into from
Aug 28, 2020
Merged

Transactions and WithDatabase #367

merged 3 commits into from
Aug 28, 2020

Conversation

cskardon
Copy link
Member

This is quite a big one:

  • This allows Transactions in both the GraphClient and BoltGraphClient
  • Transactions are started from the ITransactionalGraphClient interface, which is now easily accessible via the Tx property on an IGraphClient
using (var tx = client.Tx.BeginTransaction()){
  //Transaction stuff here

  await tx.CommitAsync();
  await tx.RollbackAsync();
}

NB if you're using a using and don't call CommitAsync it will RollbackAsync as part of the Dispose of the transaction.

  • Transactions can be against a particular database:
using (var tx = client.Tx.BeginTransaction(TransactionScopeOption.Join, null, "my-db"))
{ 
  /* Stuff here */ 
}

Attempting to run a query inside the transaction against another database will throw an InvalidOperationException - transactions can only be against one database.

NB - I know this is a clunky way of doing this - we're still in pre-release, but expect this signature to change.

  • DefaultDatabase has been added and is set on the client when instantiating. This is overridden by use of WithDatabase. This only affects connections to a 4.x database - it will do nothing on a 3.x one. If not set, this defaults to neo4j
//The 'case' of the DefaultDatabase will be 'ToLower'd as Neo4j only has lowercase database names
var client = new BoltGraphClient("neo4j://localhost:7687", "neo4j", "neo") {DefaultDatabase = "neo4jclient"};
  • WithDatabase has been added to the ICypherFluentQuery interface
await client.Cypher
    //WithDatabase here overrides 'DefaultDatabase'
    .WithDatabase("my-db")
    .Match("(n)")
    .Return(n => n.Count())
    .ResultsAsync;
  • All executions are now against the Transaction API for the GraphClient version

@cskardon cskardon merged commit fd35e35 into DotNet4Neo4j:40-development Aug 28, 2020
cskardon pushed a commit that referenced this pull request Sep 3, 2020
* Handling Encryption

* Transactional 'WithDatabase'
cskardon pushed a commit that referenced this pull request Sep 5, 2020
* Handling Encryption

* Transactional 'WithDatabase'
cskardon pushed a commit that referenced this pull request Sep 18, 2020
* change bolt client to use async endpoints of driver

* accidental change

* restructure solution for dotnet standard only

* remove all sync endpoints, move everything to async (except transactions), and delete gremlin

* add transactions

* transactions tests

* cleanup a couple of things

* Multi-targeting 4.5.2, 4.6 as well as netstandard 2.0 now

Added build constants for net45, and added the VB tests back in
Adding Version into the csproj for CI

* Updating the Readme

* It will build - but not tested. DO NOT USE.

* Preventing NCrunch solution files being committed

* Parameters all use $ syntax now

* Fixing some tests - more to go - mocking issues atm

* Removed a lot of REST/Gremlin code from the GraphClient

* `GraphClient` and `BoltGraphClient` currently connect against `4.0`

Need to test GC with 3.5 - as no longer using `cypher` endpoint for anything, only tx

* Majority of tests fixed, 3 to go

* Tests fixed

* update neo4j driver and add support for new signed and self-signed sc… (#356)

* update neo4j driver and add support for new signed and self-signed schemes

* update readme

* Moved cursor.ToListAsync inside transaction, as required for Neo4J 4.x. Also sorted out some nulls in bookmarks. (#362)

* Updating so the `Http` and `Bolt` versions work (#363)

* Transactions and WithDatabase (#367)

* Handling Encryption

* Transactional 'WithDatabase'

* Fix #386 on 4.x (#372)

* Adding `USE` to the CypherFluentQuery

* 40 development (#374)

* Tests for Transactions


Throws exceptions when cypher gives back errors

This is now for the 'ExecuteCypherNoResults' side of things

QueryStats for GraphClient - ExecuteNoResults

3.5 / 4.x

* WithQueryStats for GraphClient

* WithQueryStats for BoltGraphClient

* Manual implementation of 'Neo4jIgnoreAttribute'

To take into account changes since the PR was originally written by https://github.com/Clooney24

* 40 development (#375)

* Remove `Start`

* Create(string, params object[])

* Return<T>(string, CypherResultMode)

* StartBit (various)

* Mapper

* Hiding unused member

* Database Administration Commands

* Set capabilities properly

* Updating Readme

Co-authored-by: Toby Miller <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant