Reputation: 11
I have the following document :
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; }
}
My input is Car. I need to display in my view the car name and the CarType.Name match to CarsPriceIds
I start write my index and got stuck. Here is my index
new IndexDefinitionBuilder<Cars>
{
Map = docs => from doc in docs
from carsPriceId in doc.CarsPriceIds
from carTypes in ????
select new { doc.Name}
}
I can't continue!!! What next?? Any help please
Regards
Upvotes: 1
Views: 1861
Reputation: 6839
You have probably chosen the wrong model, because it seems that CarPrice and CarType have no meaning outside Car. Therefore they should be inside the Car document. Generally your documents are equal to your aggregate roots in DDD terms.
However, if you really want to stick with this model and just want an index that can join your CarPrices and CarTypes, take a look at this: http://ayende.com/blog/4661/ravendb-live-projections-or-how-to-do-joins-in-a-non-relational-database
Upvotes: 1
Reputation: 22956
You probably want to look at live projections:
http://ayende.com/blog/4661/ravendb-live-projections-or-how-to-do-joins-in-a-non-relational-database
Upvotes: 0