2013-03-08 72 views
0

我有以下设计:债务人由代理管理。每个文件都存储为独立的文档,并且使用基于id的引用。代理人与其债务人之间的每次通信均记录为第三个独立文件,并以债务人身份提供参考。由此容易地创建一个索引CommunicationsByDebtor,如下:如何为链接文档创建RavenDB索引

from c in docs.Communications 
select new { c.DebtorId } 

但是,我怎么定义地图索引CommunicationsByAgent? 我已经试过这一点,但不进行编译:

from c in docs.Communications 
from d in docs.Debtors 
where d.Id == c.Communication_Debtor 
select new { d.AgentId } 

任何意见,将不胜感激。

回答

1
from c in docs.Communications 
let d = LoadDocument<Debtor>(c.Communication_Debtor) 
select new { d.AgentId } 

参考:Indexing Related Documents

+0

我得到这两个错误:1)所述的非通用的方法 'Raven.Database.Linq.AbstractViewGenerator.LoadDocument(字符串)' 不能以类型参数 2)中使用类型或命名空间名称'Debtors'无法找到(你是否缺少using指令或程序集引用?)我怀疑第一个将由我得到第二个的正确类型定义解决?我已经尝试过债务人,债务人,债务人,docs.Debtor,docs.Debtors ... – 2013-03-08 15:36:03

+0

行得通......必须做到这一点...从docs.Communications 让d = LoadDocument(string.Format( “债务人/ {0}”,c.Communication_Debtor)) select new {d.AgentId} – 2013-03-08 15:47:58

+0

似乎你不能指定一个类型为LoadDocument;并且它期望变量是[collectionname]/id – 2013-03-08 15:48:46

相关问题