星空网 > 软件开发 > ASP.net

C#同步数据库的数据到Neo4J

数据组件采用https://github.com/Readify/Neo4jClient

在nuget里面有

需要注意的是

 

以下是示例代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Neo4jClient;
using Neo4jClient.Cypher;

namespace TestNeo4J
{
class Program
{
static void Main(string[] args)
{

// Init
var client = new GraphClient(new Uri("http://IP:7474/db/data"));
client.Connect();

var root = client.Get<User>(new NodeReference(0)); //获取根节点,主要是在neoclipse工具里面好浏览,如不考虑浏览,你也可以不加到根节点里面去。

// Create entities
var refA = client.Create(new User() { Name = "User A" });
var refB = client.Create(new User() { Name = "User B" });
var refC = client.Create(new User() { Name = "User C" });

client.CreateRelationship(root.Reference,new ReferralRelationship(refA));
client.CreateRelationship(root.Reference, new ReferralRelationship(refB));
client.CreateRelationship(root.Reference, new ReferralRelationship(refC));


Console.Read();
}

//static void DrawPoints(
}
}

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Neo4jClient;

namespace TestNeo4J
{

public class HatesData
{
public string Reason { get; set; }

public HatesData()
{ }

public HatesData(string reason)
{
this.Reason = reason;
}
}

public class KnowsRelationship : Relationship, IRelationshipAllowingSourceNode<User>,
IRelationshipAllowingTargetNode<User>
{
public static readonly string TypeKey = "KNOWS";

public KnowsRelationship(NodeReference targetNode)
: base(targetNode)
{ }

public override string RelationshipTypeKey
{
get { return TypeKey; }
}
}

public class ReferralRelationship : Relationship, IRelationshipAllowingSourceNode<User>,
IRelationshipAllowingTargetNode<User>
{
public static readonly string TypeKey = "Referral";

public ReferralRelationship(NodeReference targetNode)
: base(targetNode)
{ }

public override string RelationshipTypeKey
{
get { return TypeKey; }
}
}

public class User
{
public string Name { get; set; }
}
}




原标题:C#同步数据库的数据到Neo4J

关键词:C#

C#
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流