c# - When retrieving records from a MongoDb collection, do the records come back sorted based on the index that was set up for that collection? -


I have a case that looks like this: For example, there is a collection called "Archive" and I Index is set for this and the index looks something like this:

  {"A": 1, "b": 1, "c": 1}   

In my code, I am retrieving the record that holds a certain value based on "A":

  list & lt; Test & gt; Test = test Search (query .aec ("a", fixed value)). ToList ();   

And all the records are coming back for my surprise in the order stated in the index (climbing "B" climbing "C")

I was thinking If this behavior is always expected, whether the records are always sorted by the index, or are I imagining things and this is just a closed matter?

PS Records are not recorded in the archive so that it is not a natural order of records.

Just with many other dictionary implementations, and subject to change at any time: < Blockquote>

In the "Natural Order" compilation, the object is defined as the database's default command.

When performing a search () with no parameter, the database further returns the objects in the natural order.

For standard tables, natural order is not particularly useful, because it is close to entering the order, although guaranteed to be, however, for Cap Collections, the natural order guarantee for entry order She goes.

If you have some sort of sort or refer to your specific driver (C #) implementation docs, see if it's the kind of thing for you.

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -