{"id":13430353,"url":"https://github.com/neo4j/neo4j-dotnet-driver","last_synced_at":"2025-05-14T14:10:26.909Z","repository":{"id":38420631,"uuid":"49424996","full_name":"neo4j/neo4j-dotnet-driver","owner":"neo4j","description":"Neo4j Bolt driver for .NET","archived":false,"fork":false,"pushed_at":"2025-04-30T16:11:04.000Z","size":11474,"stargazers_count":233,"open_issues_count":11,"forks_count":70,"subscribers_count":70,"default_branch":"5.0","last_synced_at":"2025-04-30T17:26:36.790Z","etag":null,"topics":["binary-protocol","csharp","cypher","cypher-query","database-driver","dotnet","driver","graph-database","graph-database-neo4j","neo4j","protocol"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/neo4j.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-01-11T12:28:56.000Z","updated_at":"2025-04-30T16:11:08.000Z","dependencies_parsed_at":"2022-07-11T19:24:27.972Z","dependency_job_id":"1f5393c9-1f07-4ff0-9a8b-1e82250f7590","html_url":"https://github.com/neo4j/neo4j-dotnet-driver","commit_stats":{"total_commits":1331,"total_committers":37,"mean_commits":"35.972972972972975","dds":0.667167543200601,"last_synced_commit":"f7318f38dec62cd4157c1636e3f21b01d0db91e5"},"previous_names":[],"tags_count":106,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neo4j%2Fneo4j-dotnet-driver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neo4j%2Fneo4j-dotnet-driver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neo4j%2Fneo4j-dotnet-driver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neo4j%2Fneo4j-dotnet-driver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neo4j","download_url":"https://codeload.github.com/neo4j/neo4j-dotnet-driver/tar.gz/refs/heads/5.0","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254160558,"owners_count":22024571,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binary-protocol","csharp","cypher","cypher-query","database-driver","dotnet","driver","graph-database","graph-database-neo4j","neo4j","protocol"],"created_at":"2024-07-31T02:00:52.589Z","updated_at":"2025-05-14T14:10:21.900Z","avatar_url":"https://github.com/neo4j.png","language":"C#","funding_links":[],"categories":["Frameworks, Libraries and Tools","Connectors","框架, 库和工具","Bolt","Database Drivers"],"sub_categories":["Database Drivers","Bolt","数据库驱动程序"],"readme":"# Neo4j .NET Driver\n\nThis repository contains the official [Neo4j](https://neo4j.com/) driver for .NET.\n\n### [API Docs](https://neo4j.com/docs/api/dotnet-driver/current/) | [Driver Manual](https://neo4j.com/docs/dotnet-manual/current/) | [Example Web App](https://github.com/neo4j-examples/movies-dotnetcore-bolt) | [Change Log](https://github.com/neo4j/neo4j-dotnet-driver/wiki/5.X-Change-Log)\n\nThis document covers the usage of the driver; for contribution guidance, see [Contributing](./CONTRIBUTING.md).\n\n## Installation\n\nNeo4j publishes its .NET libraries to NuGet with the following targets:\n\n- [.NET Standard 2.0](https://learn.microsoft.com/en-us/dotnet/api/?view=netstandard-2.0), for more\n  info: https://learn.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0\n- [.NET 6.0](https://learn.microsoft.com/en-us/dotnet/api/?view=net-6.0)\n- [.NET 8.0](https://learn.microsoft.com/en-us/dotnet/api/?view=net-8.0) as of 5.17\n\nTo add the latest [NuGet package](https://www.nuget.org/packages/Neo4j.Driver):\n\n```posh\n\u003e dotnet add package Neo4j.Driver\n```\n\n### Versions\n\nStarting with 5.0, the Neo4j drivers moved to a monthly release cadence. A new minor version is released on the last\nThursday of each month to maintain versioning consistency with the core product (Neo4j DBMS), which also has moved to a\nmonthly cadence.\n\nAs a policy, Neo4j will not release patch versions except on rare occasions. Bug fixes and updates will go into the\nlatest minor version; users should upgrade to a later version to patch bug fixes. Driver upgrades within a major version\nwill never contain breaking API changes, excluding the `Neo4j.Driver.Preview` namespace reserved for the preview of\nfeatures.\n\nSee also: https://neo4j.com/developer/kb/neo4j-supported-versions/\n\n### Synchronous and Reactive driver extensions\n\n* [Neo4j.Driver.Simple](https://www.nuget.org/packages/Neo4j.Driver.Simple/) exposes synchronous APIs on the driver's\n  IDriver interface.\n* [Neo4j.Driver.Reactive](https://www.nuget.org/packages/Neo4j.Driver.Reactive/) exposes reactive APIs on the driver's\n  IDriver interface.\n\n### Strong-named\n\nA [strong-named](https://learn.microsoft.com/en-us/dotnet/standard/assembly/strong-named) version of each driver package\nis available on NuGet [Neo4j.Driver.Signed](https://www.nuget.org/packages/Neo4j.Driver.Signed). The strong-named\npackages contain the same version of\ntheir respective packages with strong-name compliance. _Consider using the strong-named version only if your project is\nstrong-named or requires strong-named dependencies._\n\nTo add the strong-named version of the driver to your project using the NuGet Package Manager:\n\n```posh\n\u003e Install-Package Neo4j.Driver.Signed\n```\n\n## Getting started\n\n### Connecting to a Neo4j database:\n\n```csharp\nusing Neo4j.Driver;\n\nawait using var driver = GraphDatabase.Driver(\"bolt://localhost:7687\", AuthTokens.Basic(\"neo4j\", \"password\"));\n```\n\nThere are a few points to highlight when adding the driver to your project:\n\n* Each `IDriver` instance maintains a pool of connections inside; as a result, use a single driver instance per\n  application.\n* Sessions and transactions do not open new connections if a free one is in the driver's connection pool; this makes\n  both resources cheap to create and close.\n* The driver is thread-safe and made to be used across an application. Sessions and transactions are not thread-safe;\n  using a session or transaction concurrently will result in undefined behavior.\n\n### Verifying connectivity:\n\n```csharp\nawait driver.VerifyConnectivityAsync();\n```\n\nTo ensure the credentials and URLs specified when creating the driver, you can call `VerifyConnectivityAsync` on the\ndriver instance. If either configuration is wrong, the Task will result in an exception.\n\n### Executing a single query transaction:\n\n```csharp\nawait driver.ExecutableQuery(\"CREATE (:Node{id: 0})\")\n    .WithConfig(new QueryConfig(database:\"neo4j\"))\n    .ExecuteAsync();\n```\n\nAs of version 5.10, The .NET driver includes a fluent querying API on the driver's IDriver interface. The fluent API is\nthe most concise API for executing single query transactions. It avoids the boilerplate that comes with handling complex\nproblems, such as results that exceed memory or multi-query transactions.\n\n### Remember to specify a database.\n\n```csharp\n    .WithConfig(new QueryConfig(database:\"neo4j\"))\n```\n\nAlways specify the database when you know which database the transaction should execute against. By setting the database\nparameter, the driver avoids a roundtrip and concurrency machinery associated with negotiating a home database.\n\n### Getting Results\n\n```csharp\nvar response = await driver.ExecutableQuery(\"MATCH (n:Node) RETURN n.id as id\")\n    .WithConfig(dbConfig)\n    .ExecuteAsync();\n```\n\nThe response from the fluent APIs is\nan [EagerResult](https://neo4j.com/docs/api/dotnet-driver/current/api/Neo4j.Driver.EagerResult-1.html)\u003c\nIReadOnlyList\u003c[IRecord](https://neo4j.com/docs/api/dotnet-driver/current/api/Neo4j.Driver.IRecord.html)\u003e\u003e unless we use\nother APIs; more on that later.\nEagerResult comprises of the following:\n\n- All records materialized(`Result`).\n- keys returned from the query(`Keys`).\n- a [query summary](https://neo4j.com/docs/api/dotnet-driver/current/api/Neo4j.Driver.IResultSummary.html)(`Summary`).\n\n#### Decomposing EagerResult\n\n```csharp\nvar (result, _, _) = await driver.ExecutableQuery(query)\n    .WithConfig(dbConfig)\n    .ExecuteAsync();\nforeach (var record in result)\n    Console.WriteLine($\"node: {record[\"id\"]}\")\n```\n\nEagerResult allows you to discard unneeded values with decomposition for an expressive API.\n\n#### Mapping\n\n```csharp\nvar (result, _, _) = await driver.ExecutableQuery(query)\n    .WithConfig(dbConfig)\n    .WithMap(record =\u003e new EntityDTO { id = record[\"id\"].As\u003clong\u003e() })\n    .ExecuteAsync();\n```\n\n## Types\n\nValues in a record are currently exposed as of `object` type.\nThe underlying types of these values are determined by their Cypher types.\n\nThe mapping between driver types and Cypher types are listed in the table bellow:\n\n|  Cypher Type | Driver Type                 \n|-------------:|:----------------------------|\n|       *null* | null                        |\n|         List | IList\u003c object \u003e             |\n|          Map | IDictionary\u003cstring, object\u003e |\n|      Boolean | boolean                     |\n|      Integer | long                        |\n|        Float | float                       |\n|       String | string                      |\n|    ByteArray | byte[]                      |\n|        Point | Point                       |\n|         Node | INode                       |\n| Relationship | IRelationship               |\n|         Path | IPath                       |\n\nTo convert from `object` to the driver type, a helper method `ValueExtensions#As\u003cT\u003e` can be used:\n\n```csharp\nIRecord record = await result.SingleAsync();\nstring name = record[\"name\"].As\u003cstring\u003e();\n```\n\n#### Temporal Types - Date and Time\n\nThe mapping among the Cypher temporal types, driver types, and convertible CLR temporal types - DateTime, TimeSpan and\nDateTimeOffset - (via `IConvertible` interface) are as follows:\n\n|  Cypher Type  |  Driver Type  |    Convertible CLR Type    |\n|:-------------:|:-------------:|:--------------------------:|\n|     Date      |   LocalDate   | DateTime, DateOnly(.NET6+) |\n|     Time      |  OffsetTime   |      TimeOnly(.NET6+)      |\n|   LocalTime   |   LocalTime   |     TimeSpan, DateTime     |\n|   DateTime    | ZonedDateTime |       DateTimeOffset       |\n| LocalDateTime | LocalDateTime |          DateTime          |\n|   Duration    |   Duration    |            ---             |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneo4j%2Fneo4j-dotnet-driver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneo4j%2Fneo4j-dotnet-driver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneo4j%2Fneo4j-dotnet-driver/lists"}