ArangoDB创建文档导致空插入

本文关键字:插入 创建 文档 ArangoDB | 更新日期: 2023-09-27 18:05:20

我在我的项目中使用"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'对象中有有效的数据!

ArangoDB创建文档导致空插入

你想要存储的类中的数据需要定义为属性,例如,因此你的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; }
}