Can I serialize a FilterDefinition<T>
to a json string to see what is being built under the hood? Or only via the logs and a more verbose database profiler setting?
Yes, FilterDefinition has a Render method on it. Provided you have access to the collection you are using, you can do the following.
var renderedFilter = definition.Render(collection.DocumentSerializer, collection.Settings.SerializerRegistry);
It will render to a BsonDocument, what you can use ToString() on that if you want the JSON.
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