Neo4j driver #835
-
I am working on a project(.NET). In this, we are only having read queries. So I just want to ensure we are not using neo4j driver wrong.
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Hi killJoy-03. Your usage of the session object and ExecuteRead method look correct. One thing to keep in mind is that behind the scenes when you call Note: if you are not batching multiple queries into a single transaction then it is also worth considering the ExecuteQuery interface on the driver object, less code and simpler to use. |
Beta Was this translation helpful? Give feedback.
-
@AndyHeap-NeoTech -- If your result set is very large then it might be worth controlling the fetching of records and working with them as they arrive in a more streaming fashion. can you explain more like after what size and some demo code |
Beta Was this translation helpful? Give feedback.
-
Hi KillJoy, apologies for the slow reply. I missed the notification of your message in my inbox. With the result cursor object you can 'fetch' records as they become available, allowing you to process them as they arrive rather than building a collection in memory and taking up that space. Under the hood the ToListAsync method is doing exactly this, but fetching all of the records into memory in one go. An example of how to do this would be:
or you can use the FetchAsync method in a loop of your own construction. |
Beta Was this translation helpful? Give feedback.
Hi KillJoy, apologies for the slow reply. I missed the notification of your message in my inbox.
With the result cursor object you can 'fetch' records as they become available, allowing you to process them as they arrive rather than building a collection in memory and taking up that space. Under the hood the ToListAsync method is doing exactly this, but fetching all of the records into memory in one go.
An example of how to do this would be: