【问题标题】:Create Index in RavenDB在 RavenDB 中创建索引
【发布时间】:2012-02-21 12:40:45
【问题描述】:

我有以下文件:

public class Cars
{
    [Key]
    public string Id { get; set; }

    public string Name { get; set; }

    //collection of car price id
    public List<string> CarsPriceIds { get; set; }
}
public class CarsPriceIds 
{
    [Key]
    public string Id { get; set; }

    public string Name { get; set; }

    public List<string> CarTypesIds { get; set; }
}

public class CarTypes
{
    [Key]
    public string Id { get; set; }

    public string Name { get; set; }

 }

我的输入是汽车。 我需要在我的视图中显示 汽车名称和 CarType.Name 与 CarsPriceIds 匹配

我开始编写索引并卡住了。这是我的索引

new IndexDefinitionBuilder<Cars>
{
  Map = docs => from doc in docs
  from carsPriceId in doc.CarsPriceIds 
  from carTypes in ????
  select new { doc.Name}
}

我不能继续!!! 接下来是什么?? 请帮忙

问候

【问题讨论】:

    标签: c# indexing ravendb


    【解决方案1】:

    您可能选择了错误的模型,因为 CarPrice 和 CarType 似乎在 Car 之外没有任何意义。因此,它们应该在 Car 文档中。通常,您的文档等于 DDD 术语中的总根。

    但是,如果您真的想坚持使用此模型并且只想要一个可以加入您的 CarPrices 和 CarTypes 的索引,请查看:http://ayende.com/blog/4661/ravendb-live-projections-or-how-to-do-joins-in-a-non-relational-database

    【讨论】:

      【解决方案2】:
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多