I declare a Filter in c# by mongodb like this:
var filters = new List<FilterDefinition<Message>>
if (!area.Equals(""))
filters.Add(Builders<Message>.Filter.Eq("Domain", area));
and work perfectly when area is a single string for example 1. but I want area is 1,2,5,55,this filter work. In order to this I have changed my filter to this:
filters.Add(Builders<Message>.Filter.AnyIn(x => x.Domain, area));
according this suggestion
but I got this error :
The serializer for field 'Domain' must implement IBsonArraySerializer and provide item serialization info.
Why am I getting this error and how can I fix it?
I have seen this post but nobody do not answer to this post.
If I have understood the question correctly, you shouyld be using the $in query:
filters.Add(Builders<Message>.Filter.In("Domain", new List<int>() { a1, a2 }));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With