public class BlogPost
{
public string Id { get; set; }
public string Title { get; set; }
public string Category { get; set; }
public string Content { get; set; }
public DateTime PublishedAt { get; set; }
public string[] Tags { get; set; }
public BlogComment[] Comments { get; set; }
}
public class BlogComment
{
public string Id{get;set;}
public string Title { get; set; }
public string Content { get; set; }
}
BlogPost post = new BlogPost()
{
Title = "Hello RavenDB",
Category = "RavenDB",
Content = "This is a blog about RavenDB",
Comments = new BlogComment[]
{
new BlogComment() {Title = "Unrealistic", Content = "This example is unrealistic"},
new BlogComment() {Title = "Nice", Content = "This example is nice"}
}
};
坚持这将导致 BlogComment 字段被嵌入到 BlogPost 文档中
RavenDB 不会为 BlogComment 字段生成 Id
我真正想要的是 BlogPost 只保留对 BlogComment 字段的引用,并将 BlogComment 实例存储为单独的实体
任何提示都会做
谢谢。我必须编辑以正确代表我的困境