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.
如果我正确理解了这个问题,您应该使用$in 查询:
filters.Add(Builders<Message>.Filter.In("Domain", List<int>(){a1,a2}));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.