ArangoDB创建文档导致空插入

har*_*ing 1 .net c# arangodb

我正在使用" 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;
    }
Run Code Online (Sandbox Code Playgroud)

这是我的课程:

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;
}
Run Code Online (Sandbox Code Playgroud)

我正在创建对象并试图获取该文档的密钥,如下所示:

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

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

yoj*_*o87 6

您希望存储的类中的数据需要定义为属性,例如,您的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; }
}
Run Code Online (Sandbox Code Playgroud)