How to request items from nested collections in Raven DB?

I have the following 2 entity models:

      public class Store : IModel
      {
        public string Id { get; set; }
        public string Name { get; set; }
        public string MainPageUrl { get; set; }
        public ICollection<Product> Products { get; set; }

      }

      public class Product : IModel {
          public string Id { get; set; }
          public string Name { get; set; }
          public double Price { get; set; }
        public DateTime Created { get; set; }
}

and from this Repository is a document in my Raven Db. I need to create an index where I can query for products by name, and the result should be partial. Keep documents containing only relevant products.

Therefore, to be specific, I need to ask Raven Db: in which stores there are products containing this text, and what are these products in each store.

Now I can make an index that allows me to store documents with the corresponding products, but it always gives me ALL products in these documents.

I believe this is very easy to answer, but being new to Raven Db and document databases, I just couldn't get the job done.

question, /.

+5
1

Mule, , , Store Document, Store. , , :

from store in docs.Stores
from product in store.Products
select new { product.Name, product.Price, product.Created, store.Id }

, , Id .

.

session.Query<StoreProduct>()
  .Where(s=>s.Name == name)
  .AsProjection<StoreProduct>()
  .ToList();

.

+6

All Articles