@@ -46,7 +46,7 @@ public ListIndexesOperation(
46
46
ReadPreference readPreference ,
47
47
BsonBinaryReaderSettings readerSettings ,
48
48
BsonBinaryWriterSettings writerSettings )
49
- {
49
+ {
50
50
if ( string . IsNullOrEmpty ( databaseName ) )
51
51
{
52
52
throw new ArgumentException ( "Database name cannot be null or empty." , "databaseName" ) ;
@@ -95,7 +95,10 @@ public IEnumerable<BsonDocument> Execute(MongoConnection connection)
95
95
96
96
private IEnumerable < BsonDocument > ExecuteUsingCommand ( MongoConnection connection )
97
97
{
98
- var command = new CommandDocument ( "listIndexes" , _collectionName ) ;
98
+ var command = new CommandDocument
99
+ {
100
+ { "listIndexes" , _collectionName }
101
+ } ;
99
102
var flags = QueryFlags . None ;
100
103
var options = new BsonDocument ( ) ;
101
104
IBsonSerializationOptions serializationOptions = null ;
@@ -118,7 +121,29 @@ private IEnumerable<BsonDocument> ExecuteUsingCommand(MongoConnection connection
118
121
throw ;
119
122
}
120
123
121
- return result . Response [ "indexes" ] . AsBsonArray . Cast < BsonDocument > ( ) ;
124
+
125
+ var cursorDocument = result . Response [ "cursor" ] ;
126
+ var cursorId = cursorDocument [ "id" ] . ToInt64 ( ) ;
127
+ var firstBatch = cursorDocument [ "firstBatch" ] . AsBsonArray . Select ( v => v . AsBsonDocument ) ;
128
+ var ns = cursorDocument [ "ns" ] . ToString ( ) ;
129
+ using ( var enumerator = new CursorEnumerator < BsonDocument > (
130
+ new ServerInstanceConnectionProvider ( connection . ServerInstance ) ,
131
+ ns ,
132
+ firstBatch ,
133
+ cursorId ,
134
+ 0 ,
135
+ 0 ,
136
+ _readerSettings ,
137
+ BsonDocumentSerializer . Instance ,
138
+ null ) )
139
+ {
140
+ var collections = new List < BsonDocument > ( ) ;
141
+ while ( enumerator . MoveNext ( ) )
142
+ {
143
+ collections . Add ( enumerator . Current ) ;
144
+ }
145
+ return collections ;
146
+ }
122
147
}
123
148
124
149
private IEnumerable < BsonDocument > ExecuteUsingQuery ( MongoConnection connection )
0 commit comments