RavenDB 的文档结构 [英] Document structure for RavenDB

查看:43
本文介绍了RavenDB 的文档结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有课

class UserActivity
{
    private IList<Activity> _activities = new List<Activity>();

    public void AddActivity(Activity activity)
    {
        _activities.Add(activity);
    }

    public IEnumerable<Activity> ActivityHistory
    {
        return _activities;
    }
}

活动历史可以有很多元素.

Activity history can have a lot of elements.

我希望将 UserActivity 存储在具有历史记录的 RavenDB 中.但是,当我第一次从 DB 获取 UserActivity 时,ActivityHistory 应该有最后 10 个项目,例如,我应该有可能加载其他项目或向集合添加新项目并保存它们.

I wish store UserActivity in RavenDB with history. But, when I get UserActivity first time from DB, ActivityHistory should have last 10 items, for example, and I should have possibility load other items or add new to collection and save them.

我该怎么做?

据我所知,我只有一种方法 - 将 UserActivity 和历史记录项分开存储.

As I understand, i have only one way - store apart UserActivity and history items.

推荐答案

耿祖,是的,您需要将文档作为一个整体来处理.您可以将部分文档投影到索引中,但这是投影,而不是实体

Gengzu, Yes, you need to deal with the document as a whole. You can project parts of the documents out into an index, but that is a projection, not an entity

这篇关于RavenDB 的文档结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆