Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/272.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# RavenDB模型设计一对多_C#_Ravendb - Fatal编程技术网

C# RavenDB模型设计一对多

C# RavenDB模型设计一对多,c#,ravendb,C#,Ravendb,如果我有一个有列表的对象。我应该将该列表存储在与对象相同的文档中,还是将该列表存储在带有引用的单独文档中。或者我应该将其存储在两者中,也不要因为照片列表对象大小会增加,谢谢您的建议 public class Album { public string Name { get; set; } //Should I store this inside of the album document? public List<Photo> Photos {get; se

如果我有一个有列表的对象。我应该将该列表存储在与对象相同的文档中,还是将该列表存储在带有引用的单独文档中。或者我应该将其存储在两者中,也不要因为照片列表对象大小会增加,谢谢您的建议

public class Album
{
    public string Name { get; set; }

    //Should I store this inside of the album document?
    public List<Photo> Photos {get; set; } 
}

public class Photo
{
    public string Title { get; set; }
}
公共类相册
{
公共字符串名称{get;set;}
//我应该将此存储在相册文档中吗?
公开列表照片{get;set;}
}
公开课照片
{
公共字符串标题{get;set;}
}

将列表存储在包含的对象/文档中。除非你有令人信服的理由去做其他事情

两者都可以接受。不过阿隆索是对的,等你有了令人信服的理由把它分开再说

一个令人信服的理由是,如果您经常需要访问相册的其他信息,并且照片列表非常大,那么您就可以使用它。另一个例子是,如果您希望在相册上跟踪版本,但不希望在照片列表上跟踪版本

第三种可能是将每张照片存储在单独的文档中,并引用相册id,而不是保留一个列表

public class Photo
{
    public string Id { get; set; }
    public string Title { get; set; }
    public string AlbumId { get; set; }
}
这实际上只是取决于什么更适合您的场景。没有一条正确的道路