如何从模型创建DB边

时间:2016-06-23 12:06:28

标签: c# orientdb

我开始使用OrientDB-NET.binary。我创建了2个类:基于基本节点的BusinessService和BusinessServiceGroup。

关系是:

  • BusinessService-> BusinessServiceGroup
  • BusinessService->的BusinessService
  • BusinessServiceGroup-> BusinessServiceGroup

我还创建了2个中级课程:

  • DependsOnBusinessService
  • InvolvesIntoBusinessServiceGroup
  • DependsOnBusinessServiceGroup

代码

public class BasicNode
{
    public ORID ORID { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
}

public class BusinessService : BasicNode
{
    public List<ORID> in_DependsOnBusinessService { get; set; }
    public List<ORID> out_DependsOnBusinessService { get; set; }
    public List<ORID> out_InvolvesInBusinessServiceGroup { get; set; }
}

public class BusinessServiceGroup : BasicNode
{
    public List<ORID> in_DependsOnBusinessServiceGroup { get; set; }
    public List<ORID> out_DependsOnBusinessServiceGroup { get; set; }
    public List<ORID> in_InvolvesIntoBusinessServiceGroup { get; set; }
}

边缘:

public class DependsOnBusinessService
{
    [OProperty(Alias = "in", Serializable = false)]
    public ORID In { get; set; }
    [OProperty(Alias = "out", Serializable = false)]
    public ORID Out { get; set; }
}

public class DependsOnBusinessServiceGroup
{
    [OProperty(Alias = "in", Serializable = false)]
    public ORID In { get; set; }
    [OProperty(Alias = "out", Serializable = false)]
    public ORID Out { get; set; }
}

public class InvolvesIntoBusinessServiceGroup
{
    [OProperty(Alias = "in", Serializable = false)]
    public ORID In { get; set; }
    [OProperty(Alias = "out", Serializable = false)]
    public ORID Out { get; set; }
}

然后我创建了“迁移”:

    [HttpGet("v1")]
    public IActionResult Index()
    {
        StringBuilder log = new StringBuilder();
        log.AppendLine("Migrating to version 1.");
        using (ODatabase database = new ODatabase(_connection.GlobalDatabaseAlias))
        {
            if (!database.Schema.IsClassExist<BusinessService>())
            {
                database
                    .Create.Class<BusinessService>()
                    .Extends<OVertex>()
                    .CreateProperties()
                    .Run();
                log.AppendLine("BusinessService vertex class has been created.");
            }

            if (!database.Schema.IsClassExist<BusinessServiceGroup>())
            {
                database
                    .Create.Class<BusinessServiceGroup>()
                    .Extends<OVertex>()
                    .CreateProperties()
                    .Run();

                log.AppendLine("BusinessServiceGroup vertex class has been created.");
            }

            if (!database.Schema.IsClassExist<InvolvesIntoBusinessServiceGroup>())
            {
                database
                    .Create.Class<InvolvesIntoBusinessServiceGroup>()
                    .Extends<OEdge>()
                    .CreateProperties()
                    .Run();

                log.AppendLine("InvolvesIntoBusinessServiceGroup edge class has been created.");
            }

            if (!database.Schema.IsClassExist<DependsOnBusinessService>())
            {
                database
                    .Create.Class<DependsOnBusinessService>()
                    .Extends<OEdge>()
                    .CreateProperties()
                    .Run();

                log.AppendLine("DependsOnBusinessService edge class has been created.");
            }

            if (!database.Schema.IsClassExist<DependsOnBusinessServiceGroup>())
            {
                database
                    .Create.Class<DependsOnBusinessServiceGroup>()
                    .Extends<OEdge>()
                    .CreateProperties()
                    .Run();

                log.AppendLine("DependsOnBusinessServiceGroup edge class has been created.");
            }
        }

        log.AppendLine("Migrating to version 1 has succeeded");

        return Ok(log.ToString());
    }

迁移成功完成但是当我打开OrientDBStudio时,我发现链接未填充ClassName。

EmptyLinks

那么我做错了什么?或者这种行为是正常的,我必须用SQL设置Classlinks。

0 个答案:

没有答案