예제 #1
0
        // constructors
        /// <summary>
        /// Initializes a new instance of the MongoCursorEnumerator class.
        /// </summary>
        /// <param name="cursor">The cursor to be enumerated.</param>
        public MongoCursorEnumerator(MongoCursor <TDocument> cursor)
        {
            _cursor         = cursor;
            _positiveLimit  = cursor.Limit >= 0 ? cursor.Limit : -cursor.Limit;
            _readPreference = _cursor.ReadPreference;
            _queryFlags     = _cursor.Flags;

            if (_readPreference.ReadPreferenceMode != ReadPreferenceMode.Primary && _cursor.Collection.Name == "$cmd")
            {
                if (cursor.Server.ProxyType == MongoServerProxyType.ReplicaSet && !CanCommandBeSentToSecondary.Delegate(_cursor.Query.ToBsonDocument()))
                {
                    // if the command can't be sent to a secondary, then we use primary here
                    // regardless of the user's choice.
                    _readPreference = ReadPreference.Primary;
                    // remove the slaveOk bit from the flags
                    _queryFlags &= ~QueryFlags.SlaveOk;
                }
            }
        }
예제 #2
0
 // constructors
 /// <summary>
 /// Initializes a new instance of the MongoCursorEnumerator class.
 /// </summary>
 /// <param name="cursor">The cursor to be enumerated.</param>
 public MongoCursorEnumerator(MongoCursor <TDocument> cursor)
 {
     _cursor        = cursor;
     _positiveLimit = cursor.Limit >= 0 ? cursor.Limit : -cursor.Limit;
 }
 // constructors
 /// <summary>
 /// Initializes a new instance of the MongoCursorEnumerator class.
 /// </summary>
 /// <param name="cursor">The cursor to be enumerated.</param>
 public MongoCursorEnumerator(MongoCursor <TDocument> cursor)
 {
     _cursor         = cursor;
     _readPreference = _cursor.ReadPreference;
 }