我正在使用" 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的调试器中它告诉我在&#39中有有效的数据;的dataType'对象!
答案 0 :(得分: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; }
}