RavenDBに付属するサンプルデータベースにはAlbums
ドキュメントコレクションがあり、それぞれに次のGenre
ようにドキュメントが埋め込まれています。
{
... other stuff...
"Genre": {
"Id": "genres/1",
"Name": "Rock"
},
... other stuff...
}
Genre
ここでhasId
とName
fieldsに注意してください。
Genre
しかし、ドキュメントを見ると、次のようなId
、、、Name
およびDescription
フィールドがあります。
{
"Description": "Rock and Roll is a form of rock music developed in the 1950s and 1960s. Rock music combines many kinds of music from the United States, such as country music, folk music, church music, work songs, blues and jazz.",
"Name": "Rock"
}
コードをモデル化して、独自のドキュメントを保存するときと、ドキュメントを保存して埋め込むときとで、シリアル化と保存方法が異なるようにするにはどうStore()
すればよいですか?SaveChanges()
Genre
Album
Genre