Article DetailsDetailsHelp DetailsThe AsyncSession object in the Neo4j's official .NET driver has a ReadTransactionAsync method that you can use for marking read queries explicitly. For Version 4 of the driver, the below example using the ReadTransactionAsync function is correct: private async Task GetActors(IAsyncTransaction tx, string title) { var result = await tx.RunAsync("MATCH (p:Person)-[:ACTED_IN]->(m) "+ "WHERE toLower(m.title) CONTAINS toLower($title) "+ "RETURN DISTINCT p.name as actorsTx", new { title }); while (await result.FetchAsync()) { var record = result.Current; Console.WriteLine($"{record["a.name"]} knows {record["b.name"]}"); } } public async Task GetMovieActors(string movieName) { using (var session = Driver.AsyncSession()) { await session.ReadTransactionAsync(tx => GetActors(tx, movieName)); } } For Version 5 of the driver, you need to use the ExecuteReadAsync function instead: private async Task GetActors(IAsyncTransaction tx, string title) { var result = await tx.RunAsync("MATCH (p:Person)-[:ACTED_IN]->(m) "+ "WHERE toLower(m.title) CONTAINS toLower($title) "+ "RETURN DISTINCT p.name as actorsTx", new { title }); while (await result.FetchAsync()) { var record = result.Current; Console.WriteLine($"{record["a.name"]} knows {record["b.name"]}"); } } public async Task GetMovieActors(string movieName) { using (var session = Driver.AsyncSession()) { await session.ExecuteReadAsync(tx => GetActors(tx, movieName)); } } InformationTitleHow to mark queries as READ transactions in the official Neo4j .NET driver?Article Created Date3/15/2024, 10:57 PMURL Name7182631957779-How-to-mark-queries-as-READ-transactions-in-the-official-Neo4j-NET-driverLast Modified Date3/20/2024, 6:58 PM