Ravendb 索引和转换器中相同DocumentId的多个LoadDocument

Ravendb 索引和转换器中相同DocumentId的多个LoadDocument,ravendb,Ravendb,让我们以RavenDb文档中的简单索引为例: public class SampleIndex : AbstractIndexCreationTask<Invoice> { public SampleIndex() { Map = invoices => from invoice in invoices select new {

让我们以RavenDb文档中的简单索引为例:

public class SampleIndex : AbstractIndexCreationTask<Invoice>
{
    public SampleIndex()
    {
        Map = invoices => from invoice in invoices
                          select new
                          {
                              CustomerId = invoice.CustomerId,
                              CustomerName = LoadDocument<Customer>(invoice.CustomerId).Name
                          };
    }
}
公共类SampleIndex:AbstractIndexCreationTask
{
公共样本索引()
{
映射=发票=>来自发票中的发票
选择新的
{
CustomerId=发票。CustomerId,
CustomerName=LoadDocument(invoice.CustomerId).Name
};
}
}

假设我需要在索引或转换器中有多个客户属性。我应该每次调用
LoadDocument(invoice.CustomerId).SomeProperty
(可能是RavenDb优化它并实际加载文档一次),还是有任何特殊语法(类似于LINQ中的
let

您可以使用
。在查询中包括(invoice=>invoice.CustomerId)
,因此,所有引用的客户都将返回结果。请参阅。

LoadDocument是缓存的,因此对同一文档调用一次或多次并不重要。

虽然这在常规查询中是可能的,但据我所知,他问的是关于不支持
Include()
的索引的问题。