2

I was trying to achieve exactly what is described in Querying a child collection by multiple values in RavenDB, but when I try to implement it, I can't seem to the location of method Project and class Field as suggested in this snippet from that original question.

public class Products_ByCategoryIdAndSpecs_SortByTotalSold : AbstractIndexCreationTask<Product>
{
    public Products_ByCategoryIdAndSpecs_SortByTotalSold()
    {
        this.Map = products => from product in products
                               select new
                               {
                                   product.CategoryId,
                                   _ = Project(product.Specs, spec => new Field("Spec_" + spec.Key, spec.Value, Field.Store.NO, Field.Index.ANALYZED)),
                                   product.TotalSold
                               };
    }
}

I am using unstable build 721 of RavenDB

Community
  • 1
  • 1
SoManyDetails
  • 149
  • 2
  • 8

2 Answers2

1

ErikR, You need to use the syntax outlined here:

http://ravendb.net/docs/client-api/advanced/dynamic-fields

Ayende Rahien
  • 22,925
  • 1
  • 36
  • 41
  • Hehe.. imagine that the answer was in the documentation. I am sorry I neglected to look there. Being a bit new to RavenDB I am a bit confused by the somewhat outdated information that can be found and also blinded by the power of google. I shall make a mental note to go look in the documentation in my future search efforts. I have a little problem with compiling my CreateField based solution stolen from the link above. The compiler complains that "An expression tree may not contain a named argument specification". I am not very used to named parameters. Can you help me with this too? :) – SoManyDetails Mar 27 '12 at 08:42
0

Looks like you want to use the new .Intersect() feature that has been added by Matt Warren just a few days ago. Seems to be a perfect solution for the question you have linked. Take a look here: http://issues.hibernatingrhinos.com/issue/RavenDB-51

Daniel Lang
  • 6,819
  • 4
  • 28
  • 54
  • I am not suer that this is what I am after.. I like the idea to be able to query for more than one "specification" at the same time. That will come in handy later.. but now I am more interested in generating the index fields from the dictionary, using key for field name and value for term (or whatever the proper words for it may be.. :) ) I think that this is what the linked question is about, but I may be wrong. – SoManyDetails Mar 26 '12 at 21:43