我是OrientDb的新手(通常是noSQL数据库),并且已经组装了一个小型应用程序,以使用OrientDB.NETStandard-1.5 nuget package对“朋友”关系进行建模。
理想情况下,“ FriendOf”边缘只是两个Person顶点之间的链接,我在OrientDb documentation上读过,使用轻量级边缘可以提高性能。禁用轻量级边缘时,以下代码可以正常工作。但是,启用它们时,创建边的线会挂起。
我想念什么吗?
public static void EnableLightweightEdges(ODatabase orient)
{
orient.Command("ALTER DATABASE custom useLightweightEdges=true");
}
public static void DisableLightweightEdges(ODatabase orient)
{
orient.Command("ALTER DATABASE custom useLightweightEdges=false");
}
public ODatabase Connect()
{
return new ODatabase(_connectionOptions);
}
public void EnsureCreated()
{
using (var orient = Connect())
{
DisableLightweightEdges(orient);
if (!orient.Schema.IsClassExist<Person>())
{
orient.Create.Class<Person>().Extends<OVertex>().CreateProperties().Run();
}
if (!orient.Schema.IsClassExist("FriendOf"))
{
orient.Create.Class("FriendOf").Extends<OEdge>().Run();
}
CreatePeople(orient);
}
}
private static void CreatePeople(ODatabase orient)
{
// Clear existing data
orient.Delete.Edge("FriendOf").Run();
orient.Delete.Vertex<Person>().Run();
var person1 = new Person {Id = Guid.Parse("199a5b7a-b4fe-4927-901b-d5b5d2226045"), Name = "Person1"};
var person1Vertex = orient.Create.Vertex(person1).Run();
var person2 = new Person {Id = Guid.Parse("5dee19d8-86f0-41a8-b2d8-62a77f80b6d1"), Name = "Person2"};
var person2Vertex = orient.Create.Vertex(person2).Run();
orient.Create.Edge("FriendOf").From(person1.ORID).To(person2.ORID).Run();
}