0
私は動的にmongodbクエリを作成していますが、$ regexを使用すると例外がスローされます。シェルで直接使用するとクエリが機能します。
提案がありますか?私は本当に動的クエリを使用する必要があります。
method: this.Collection.Find(query).Limit(limit).ToListAsync(cancellationToken);
query: { $and: [ { Name: { '$regex': /batman/i } } ] }
exception:'BsonSerializer.Deserialize<BsonDocument>("{ $and: [ { Name: { '$regex': /batman/i } } ] }")' threw an exception of type 'System.FormatException'
Data: {System.Collections.ListDictionaryInternal}
HResult: -2146233033
HelpLink: null
InnerException: null
Message: "JSON reader expected a string but found '/batman/i'."
Source: "MongoDB.Bson"