Closed Osypchuk closed 12 years ago
and just for exact understanding of database scheme, here is current working query executed one by one:
result = _products.AsQueryable().Where(p => p.Categories.Any(c => c.Id == category.Id)).Count();
Anyway, thanks for your efforts with FLuentMongo!
Yeah, currently, we do not support SelectMany. It is a super pain to implement and I haven't needed it yet, so it is unimplemented.
I'll mark it as a feature request so I don't lose it, but I wouldn't wait on this from me. Underneath, any group by statement like this is going to generate a map/reduce call to mongodb. My suggestion is to build this map reduce yourself. Also, just as an FYI, map/reduce with mongodb is not meant for real-time querying, but rather as a backend process because it can be slow.
This is a duplicate of the SelectMany issue.
Hello,
I am trying to calculate how many products are in each category.
Every product may belong to few categories. Here is quiery which I try to implement but I get SelectMany not supported exeption. Maybe there is some other ways to do the same?
var rresult = from pc in _products.AsQueryable().SelectMany(p => p.Categories) group pc by pc.Id into g select new { Id = g.Key, Count = g.Count() };
Thanks in advance