├── _config.yml
├── icon
├── NeoClient.png
└── NeoClient_nuget.png
├── NeoClient.Tests
├── IntegrationTests.cs
├── Models
│ └── User.cs
├── resources
│ └── docker-compose.yml
├── NeoClient.Tests.csproj
└── IntegrationTestBase.cs
├── NeoClient
├── Attributes
│ ├── Direction.cs
│ ├── NotMappedAttribute.cs
│ └── RelationShipAttribute.cs
├── TransactionManager
│ ├── IInternalTransaction.cs
│ ├── ITransaction.cs
│ └── Transaction.cs
├── Extensions
│ ├── DateTimeExtensions.cs
│ ├── DictionaryExtensions.cs
│ ├── StatementResultExtensions.cs
│ ├── CollectionExtensions.cs
│ └── ObjectExtensions.cs
├── EntityBase.cs
├── Utilities
│ └── StringFormatter.cs
├── NeoClient.csproj
├── Templates
│ └── QueryTemplates.cs
├── INeoClient.cs
└── NeoClient.cs
├── LICENSE
├── NeoClient.sln
├── .github
└── workflows
│ └── main.yml
├── .gitignore
└── README.md
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-midnight
--------------------------------------------------------------------------------
/icon/NeoClient.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OKTAYKIR/NeoClient/HEAD/icon/NeoClient.png
--------------------------------------------------------------------------------
/icon/NeoClient_nuget.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OKTAYKIR/NeoClient/HEAD/icon/NeoClient_nuget.png
--------------------------------------------------------------------------------
/NeoClient.Tests/IntegrationTests.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OKTAYKIR/NeoClient/HEAD/NeoClient.Tests/IntegrationTests.cs
--------------------------------------------------------------------------------
/NeoClient/Attributes/Direction.cs:
--------------------------------------------------------------------------------
1 | namespace NeoClient.Attributes
2 | {
3 | public enum DIRECTION
4 | {
5 | INCOMING,
6 | OUTGOING
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/NeoClient/Attributes/NotMappedAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace NeoClient.Attributes
4 | {
5 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
6 | public class NotMappedAttribute : Attribute
7 | {
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/NeoClient/TransactionManager/IInternalTransaction.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace NeoClient.TransactionManager
4 | {
5 | internal interface IInternalTransaction : IDisposable
6 | {
7 | Neo4j.Driver.V1.ITransaction CurrentTransaction { get; }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/NeoClient/TransactionManager/ITransaction.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace NeoClient.TransactionManager
4 | {
5 | public interface ITransaction : IDisposable
6 | {
7 | void BeginTransaction();
8 | void Commit();
9 | void Rollback();
10 | bool InTransaction { get; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/NeoClient.Tests/Models/User.cs:
--------------------------------------------------------------------------------
1 | namespace NeoClient.Tests.Models
2 | {
3 | public class User : EntityBase
4 | {
5 | public User() : base(label: "User") { }
6 |
7 | public string FirstName { get; set; }
8 | public string LastName { get; set; }
9 | public string Email { get; set; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/NeoClient/Extensions/DateTimeExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace NeoClient.Extensions
4 | {
5 | public static class DateTimeExtensions
6 | {
7 | internal static double ToTimeStamp(this DateTime source)
8 | {
9 | return (source - new DateTime(1970, 1, 1)).TotalMilliseconds;
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/NeoClient/EntityBase.cs:
--------------------------------------------------------------------------------
1 | namespace NeoClient
2 | {
3 | public abstract class EntityBase
4 | {
5 | public EntityBase(string label)
6 | {
7 | Label = label;
8 | }
9 |
10 | public string Label { get; internal set; }
11 | public string Uuid { get; internal set; }
12 | public bool IsDeleted { get; internal set; }
13 | }
14 | }
--------------------------------------------------------------------------------
/NeoClient/Attributes/RelationShipAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace NeoClient.Attributes
6 | {
7 | [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
8 | public class RelationshipAttribute : Attribute
9 | {
10 | public DIRECTION Direction { get; set; } = DIRECTION.INCOMING;
11 | public string Name { get; set; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/NeoClient.Tests/resources/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 |
3 | networks:
4 | neo4j-network:
5 | driver: bridge
6 |
7 | services:
8 | neo4j:
9 | image: neo4j
10 | restart: unless-stopped
11 | ports:
12 | - 7474:7474
13 | - 6477:6477
14 | - 7687:7687
15 | environment:
16 | - NEO4J_AUTH=neo4j/changeme
17 | - NEO4J_dbms_connector_bolt_advertised__address='localhost:7687'
18 | - NEO4J_dbms_connector_bolt_tls__level=DISABLED
19 | networks:
20 | - neo4j-network
21 |
--------------------------------------------------------------------------------
/NeoClient.Tests/NeoClient.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp3.1
5 |
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/NeoClient/Utilities/StringFormatter.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 |
4 | namespace NeoClient.Utilities
5 | {
6 | public class StringFormatter
7 | {
8 | public string Str { get; set; }
9 |
10 | public Dictionary Parameters { get; set; }
11 |
12 | public StringFormatter(string p_str)
13 | {
14 | Str = p_str;
15 | Parameters = new Dictionary();
16 | }
17 |
18 | public void Add(string key, object val)
19 | {
20 | Parameters.Add(key, val);
21 | }
22 |
23 | public bool Remove(string key)
24 | {
25 | return Parameters.Remove(key);
26 | }
27 |
28 | public override string ToString()
29 | {
30 | return Parameters.Aggregate(Str, (current, parameter) => current.Replace(parameter.Key, parameter.Value.ToString()));
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/NeoClient/Extensions/DictionaryExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | namespace NeoClient.Extensions
6 | {
7 | public static class DictionaryExtensions
8 | {
9 | public static void Map(this IReadOnlyDictionary dict, T obj)
10 | {
11 | var type = typeof(T);
12 | var properties = type.GetProperties().Where(p => p.CanRead && p.CanWrite && dict.ContainsKey(p.Name));
13 |
14 | foreach (var property in properties)
15 | {
16 | var value = Convert.ChangeType(dict[property.Name], property.PropertyType);
17 | property.SetValue(obj, value);
18 | }
19 | }
20 |
21 | public static T Map(this IReadOnlyDictionary dict) where T : new()
22 | {
23 | var result = new T();
24 |
25 | Map(dict, result);
26 |
27 | return result;
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/NeoClient.Tests/IntegrationTestBase.cs:
--------------------------------------------------------------------------------
1 | using Neo4j.Driver.V1;
2 | using System;
3 |
4 | namespace NeoClient.Tests
5 | {
6 | public abstract class IntegrationTestBase : IDisposable
7 | {
8 | #region Variables
9 | internal const string URL = "bolt://localhost:7687";
10 | internal const string USER = "neo4j";
11 | internal const string PASSWORD = "changeme";
12 | internal static readonly Config CONFIG = Config.Builder
13 | .WithEncryptionLevel(EncryptionLevel.None)
14 | .ToConfig();
15 | #endregion
16 |
17 | public virtual void Dispose(bool isDisposing)
18 | {
19 | if (!isDisposing)
20 | return;
21 |
22 | using (INeoClient client = new NeoClient(URL, USER, PASSWORD, CONFIG))
23 | {
24 | client.Connect();
25 | client.RunCustomQuery("MATCH (n) DETACH DELETE n");
26 | }
27 | }
28 |
29 | public void Dispose()
30 | {
31 | Dispose(true);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Oktay Kır , PhD
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/NeoClient/Extensions/StatementResultExtensions.cs:
--------------------------------------------------------------------------------
1 | using Neo4j.Driver.V1;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 |
6 | namespace NeoClient.Extensions
7 | {
8 | public static class StatementResultExtensions
9 | {
10 | public static T Map(this IStatementResult statementResult) where T : new()
11 | {
12 | var recordValue = statementResult?.FirstOrDefault()?[0];
13 |
14 | if (recordValue == null)
15 | return default;
16 |
17 | var properties = recordValue.As().Properties;
18 |
19 | return properties == null ? default : properties.Map();
20 | }
21 |
22 | public static IList