How to find documents from array elements

47 Views Asked by At

I can't find help in web about it.

I use C# and I have one collection where I stored _ids, usersEmails, and productId (objectId).

Okey, I get whole collection and then I want find in my other collection -"Products" documents which are fit to _id from Products.

short version Collections:

SmallDictionary

_id as Id, UserEmail, ProductId.

===================================

Products

_id, Name, Price.

The Products collection has a lot of data, so I don't want make foreach, because it is too long (about 3 secods) I need fastest.

I try used Builder, but doesn't work...

var collection = database.GetCollection<SmallDictionary>("SmallDictionary")

var a = collection.Find(x => x.EmailUser == userEmail).ToList();

var filter = Builders<ShopProducts>.Filter.AnyIn(a => a.Id, a);

Of course this above doesn't work.

Could somebody help me ? Please :)

0

There are 0 best solutions below