{"id":29095380,"url":"https://github.com/oktaykir/neoclient","last_synced_at":"2025-06-28T11:02:09.410Z","repository":{"id":51208764,"uuid":"256479333","full_name":"OKTAYKIR/NeoClient","owner":"OKTAYKIR","description":":owl: Lightweight OGM for Neo4j which support transactions and BOLT protocol.","archived":false,"fork":false,"pushed_at":"2021-05-18T18:58:04.000Z","size":200,"stargazers_count":23,"open_issues_count":2,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-28T08:15:27.513Z","etag":null,"topics":["bolt","c-sharp","cypher","cypher-query","dotnet-framework","dotnet-standard","graph-database","graphdb","mapper","neo4j","net-core","nosql","ogm-neo4j"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OKTAYKIR.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-17T11:02:45.000Z","updated_at":"2024-12-14T15:36:08.000Z","dependencies_parsed_at":"2022-09-23T02:13:01.111Z","dependency_job_id":null,"html_url":"https://github.com/OKTAYKIR/NeoClient","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/OKTAYKIR/NeoClient","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OKTAYKIR%2FNeoClient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OKTAYKIR%2FNeoClient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OKTAYKIR%2FNeoClient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OKTAYKIR%2FNeoClient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OKTAYKIR","download_url":"https://codeload.github.com/OKTAYKIR/NeoClient/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OKTAYKIR%2FNeoClient/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262419689,"owners_count":23308092,"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":["bolt","c-sharp","cypher","cypher-query","dotnet-framework","dotnet-standard","graph-database","graphdb","mapper","neo4j","net-core","nosql","ogm-neo4j"],"created_at":"2025-06-28T11:01:15.924Z","updated_at":"2025-06-28T11:02:09.404Z","avatar_url":"https://github.com/OKTAYKIR.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003cimg src=\"icon/NeoClient.png\" width=\"440\" alt=\"NeoClient logo\"/\u003e\n\n# NeoClient\n![Hits](https://hitcounter.pythonanywhere.com/count/tag.svg?url=https://github.com/OKTAYKIR/NeoClient)\n![GitHub issues](https://img.shields.io/github/issues/OKTAYKIR/NeoClient)\n![Build Status](https://github.com/OKTAYKIR/NeoClient/workflows/CI/badge.svg?branch=master) \n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](#contributing)\n[![nuget](https://img.shields.io/nuget/v/NeoClient)](https://www.nuget.org/packages/NeoClient/)\n\nA Lightweight and simple object graph mapper (OGM) for [Neo4j](https://neo4j.com) which support transactions and BOLT protocol.\n\n## :package: Installation\nNeoClient is available on [NuGet](https://www.nuget.org/packages/NeoClient/). \n\n```sh\ndotnet add package NeoClient\n```\n## Examples\n* **[NeoClient](https://github.com/OKTAYKIR/NeoClientDemo):** Neo4j Movies Example Application - Asp.net WebApi Version\n\n## 🚀 Usage\n\n### Creating Database Connection\nOptional you can pass authentication credential via the constructor.\n```csharp\nINeoClient client = new NeoClient(\n    uri: \"bolt://localhost:7687\", \n    userName: \"user\", //optional\n    password: \"password\", //optional\n    config: Config.Builder //optional\n        .WithMaxConnectionLifetime(TimeSpan.FromMinutes(30))\n        .WithMaxConnectionPoolSize(100)\n        .WithConnectionAcquisitionTimeout(TimeSpan.FromMinutes(2))\n        .WithEncryptionLevel(EncryptionLevel.None)\n        .ToConfig() \n    strip_hyphens: true //optional, default is false\n);\nclient.Connect();\n```\n\nFor example, if you were using any IoC container, you could register the client like so:\n```csharp\ncontainer.Register\u003cINeoClient\u003e((c, p) =\u003e\n{\n    INeoClient client = new NeoClient(\n        uri: \"bolt://localhost:7687\", \n        ...\n        );\n    client.Connect();\n    return client;\n});\n```\n### User Node Model\n```csharp\n public class User : EntityBase\n {\n     public User() : base(label: \"User\") { }\n     \n     public string FirstName { get; set; }\n     public string LastName { get; set; }\n     public string Email { get; set; }\n }\n```\n\n### Creating a Node\n```csharp\nUser entity = client.Add(new User { Email = \"kir.oktay@gmail.com\", FirstName = \"Oktay\", LastName = \"Kir\" });\n```\n\n### Adding a Label to a Node\n```csharp\nbool result = client.AddLabel(\n    uuid: \"01a68df3-cc35-4eb0-a199-0d924da86eab\",\n    labelName: @\"LabelName\"\n);\n```\n\n### Retrieving a Node by Id\n```csharp\nUser node = client.GetByUuidWithRelatedNodes\u003cUser\u003e(\"01a68df3-cc35-4eb0-a199-0d924da86eab\");\n```\n\n### Retrieving All Nodes\n```csharp\nIList\u003cUser\u003e nodes = client.GetAll\u003cUser\u003e();\n```\n\n### Retrieving Nodes by Single Property\n```csharp\nIList\u003cUser\u003e nodes = client.GetByProperty\u003cUser\u003e(\"Email\", \"kir.oktay@gmail.com\");\n```\n\n### Retrieving Nodes by Multiple Properties\n```csharp\nvar properties = new Dictionary\u003cstring, object\u003e(){\n\t{ nameof(User.Name), \"keanu\"},\n};\n\nIList\u003cUser\u003e nodes = client.GetByProperties\u003cUser\u003e(properties);\n```\n\n### Updating a Node\n```csharp\nUser updatedNode = client.Update(\n    entity: node,\n    uuid: \"01a68df3-cc35-4eb0-a199-0d924da86eab\",\n    fetchResult: true //optional, default is false\n);\n```\n\n### Deleting a Node (Soft Delete)\n```csharp\nUser node = client.Delete\u003cUser\u003e(\"01a68df3-cc35-4eb0-a199-0d924da86eab\");\n```\n\n### Dropping a Node by Id\n```csharp\nbool result = client.Drop\u003cUser\u003e(\"01a68df3-cc35-4eb0-a199-0d924da86eab\");\n```\n\n### Drop Nodes by Properties\n```csharp\nint nodesDeleted = client.DropByProperties\u003cUser\u003e(\n    props: new Dictionary\u003cstring, object\u003e(){\n        { nameof(User.Name), \"keanu\"},\n    }\n);\n```\n\n### Create a Relationship Between Certain Two Nodes\n```csharp\nbool isCreated = client.CreateRelationship(\n    uuidFrom: \"2ac55031-3089-453a-a858-e1a9a8b68a16\",\n    uuidTo: \"ac43523a-a15e-4d25-876e-e2a2cc4de125\",\n    relationshipAttribute: new RelationshipAttribute{\n        Direction = DIRECTION.INCOMING,\n        Name = \"FAMILY\"\n    },\n    props: new Dictionary\u003cstring, object\u003e(){ //optional\n        {\"CreatedAt\", DateTime.UtcNow},\n        {\"Kinship_Level\", 1},\n\t    {\"Name\", \"FakeName\"}\n    }\n);\n```\n\n### Dropping a Relationship Between Certain Two Nodes \n```csharp\nbool result = client.DropRelationshipBetweenTwoNodes(\n    uuidFrom: \"2ac55031-3089-453a-a858-e1a9a8b68a16\",\n    uuidTo: \"ac43523a-a15e-4d25-876e-e2a2cc4de125\",\n    relationshipAttribute: node.GetRelationshipAttributes(ep =\u003e ep.roles).FirstOrDefault()\n);\n```\n\n### Merge Nodes\nCreating a node with its properties on creation time. If the nodes had already been found, different multiple properties would have been set.\n```csharp\nUser node = client.Merge(\n    entityOnCreate: new User(){ name = \"keanu\"; createdAt = DateTime.UtcNow.ToTimeStamp(); },\n    entityOnUpdate: new User(){ name = \"keanu\"; updatedAt = DateTime.UtcNow.ToTimeStamp(); },\n    where: \"name:\\\"keanu\\\"\"\n);\n```\n\n### Merge Relationships\n```csharp\nbool result = client.MergeRelationship(\n    uuidFrom: \"2ac55031-3089-453a-a858-e1a9a8b68a16\",\n    uuidTo: \"ac43523a-a15e-4d25-876e-e2a2cc4de125\",\n    relationshipAttribute: node.GetRelationshipAttributes(ep =\u003e ep.roles).FirstOrDefault()\n);\n```\n\n### Running Custom Cypher Query\n#### Example 1:\n```csharp\nstring cypherCreateQuery = @\"CREATE (Neo:Crew {name:'Neo'}), \n    (Morpheus:Crew {name: 'Morpheus'}), \n    (Trinity:Crew {name: 'Trinity'}), \n    (Cypher:Crew:Matrix {name: 'Cypher'}), \n    (Smith:Matrix {name: 'Agent Smith'}), \n    (Architect:Matrix {name:'The Architect'}),\n    (Neo)-[:KNOWS]-\u003e(Morpheus), \n    (Neo)-[:LOVES]-\u003e(Trinity), \n    (Morpheus)-[:KNOWS]-\u003e(Trinity),\n    (Morpheus)-[:KNOWS]-\u003e(Cypher), \n    (Cypher)-[:KNOWS]-\u003e(Smith), \n    (Smith)-[:CODED_BY]-\u003e(Architect)\";\n\nIStatementResult result = client.RunCustomQuery(query: cypherQuery);\n\nstring cypherQuery = @\"MATCH (n:Crew)-[r:KNOWS*]-(m) WHERE n.name='Neo' RETURN n AS Neo,r,m\";\n\nIStatementResult queryResult = client.RunCustomQuery(query: cypherQuery);\nIList\u003cobject\u003e result = queryResult.GetValues();\n```\n#### Example 2:\n```csharp\nstring cypherQuery = @\"MATCH (n:User) RETURN n\";\n\nIList\u003cUser\u003e result = client.RunCustomQuery\u003cUser\u003e(query: cypherQuery);\n```\n## Integration Tests\nNeoClient has several tests that verify that its ability to use the system it integrates with correctly.\n\nThere's a [docker-compose](NeoClient.Tests/resources/docker-compose.yml) file and you can use the following command to launch Neo4j container for running the integration tests.\n```\n$ docker-compose up -d\n```\n\n## Transactions\n\n## To Do\n- [x] Nuget package\n- [x] Integration Tests\n- [x] Creating example projects\n- [ ] Supporting more functionalities\n\n## 🤝 Contributing\n1. Fork it ( https://github.com/OKTAYKIR/NeoClient/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## ✨ Contributors\n![GitHub Contributors Image](https://contrib.rocks/image?repo=OKTAYKIR/NeoClient)\n\n## Show your support\nPlease ⭐️ this repository if this project helped you!\n\n## 📝 License\n[MIT license](http://www.opensource.org/licenses/Mit)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foktaykir%2Fneoclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foktaykir%2Fneoclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foktaykir%2Fneoclient/lists"}