EDITAR:a partir de la versión 2.0.1 del controlador, FindFluent
objeto devuelto por IMongoCollection.Find
tiene un ToString
apropiado que incluye el filtro, pero también una proyección, clasificación, etc. (si corresponde).
Entonces, para esto:
var findFluent = collection.
Find(x => hashValues.Contains(x.UrlHash) && x.ProductTopic == topicId,
new FindOptions {MaxTime = TimeSpan.FromSeconds(1)}).
Project(x => x.UrlHash).
Sort(Builders<ProductMapping>.Sort.Descending(x => x.ProductTopic)).
Skip(6).
Limit(7);
Console.WriteLine(findFluent);
La salida sería:
find({ "UrlHash" : { "$in" : [4, 5, 6, 7, 8] }, "ProductTopic" : 200 }, { "UrlHash" : 1, "_id" : 0 }).
sort({ "ProductTopic" : -1 }).
skip(6).
limit(7).
maxTime(1000)
Bueno, ya sabes que estás haciendo una búsqueda, así que asumo que quieres saber cómo se ve la consulta.
Puede hacerlo fácilmente directamente desde su código usando IFindFluent.Filter
:
BsonDocument filterDocument = findFluent.Filter.Render(
collection.DocumentSerializer,
collection.Settings.SerializerRegistry);
Console.WriteLine(filterDocument);
La salida en su caso (depende de hashValues
y topicId
por supuesto):
{ "UrlHash" : { "$in" : [4, 5, 6, 7, 8, 9] }, "ProductTopic" : 200 }