【问题标题】:ArangoDB Creating Document leads to empty insertsArangoDB 创建文档导致空插入
【发布时间】:2015-07-29 18:49:47
【问题描述】:

我在我的项目中使用“https://github.com/yojimbo87/ArangoDB-NET”,试图从 xml 文件中导入数据。调试代码显示值在对象内,但是在集合内创建文档时,会导致插入空。

这是我的 createDocument 方法:

static string createDocument(ADatabase db, string collection, object dataType)
    {
        var createDocumentResult = db.Document.WaitForSync(false).Create(collection, dataType);
        string key = "";
        if (createDocumentResult.Success)
        {
            key = createDocumentResult.Value.String("_key");
        }
        return key;
    }

这是我的课程:

class Artist
{
    public int Id;
    public string Name;
    public bool Extra;
}

class ReleaseArtist
{
    public string ReleaseKey;
    public string ArtistKey;
}

class Format
{
    public string Name;
}

class ReleaseFormat
{
    public string ReleaseKey;
    public string FormatKey;
}

class Genre
{
    public string Name;
}

class ReleaseGenre
{
    public string ReleaseKey;
    public string GenreKey;
}

class Style
{
    public string Name;
}

class ReleaseStyle
{
    public string ReleaseKey;
    public string StyleKey;
}

class Track
{
    public string Position;
    public string Title;
    public string Duration;
}

class ReleaseTrack
{
    public string ReleaseKey;
    public string TrackKey;
}

class Release
{
    public int Id;
    public string Status;
    public string Title;
    public string Released;
    public string Country;
}

我正在创建对象并尝试像这样获取该文档的密钥:

 Release album = new Release { Id = releaseId, Status = releaseStatus, Title = releaseTitle, Country = releaseCountry, Released = releaseReleased };
                string releaseKey = createDocument(db, "Release", album);

不幸的是,就像说的那样,当我查看 Arango-DB 的管理区域时,它显示插入的对象是空的,即使在 Visual Studio 的调试器中它说我在“dataType”中有有效数据对象!

【问题讨论】:

  • 你能用wireshark看看电线上有什么吗?内容是否在驱动中丢失?
  • 你能给我简短的说明一下如何使用wireshark吗?我只是在后台启动它,但端口 8529 没有显示任何内容

标签: c# .net arangodb


【解决方案1】:

您想要存储的类中的数据需要定义为属性,例如因此,您的 Release 课程应如下所示:

public class Release
{
    public int Id { get; set; }
    public string Status { get; set; }
    public string Title { get; set; }
    public string Released { get; set; }
    public string Country { get; set; }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多