@@ -173,6 +173,7 @@ public virtual long Count(IMongoQuery query)
173
173
/// <param name="keys">The indexed fields (usually an IndexKeysDocument or constructed using the IndexKeys builder).</param>
174
174
/// <param name="options">The index options(usually an IndexOptionsDocument or created using the IndexOption builder).</param>
175
175
/// <returns>A WriteConcernResult.</returns>
176
+ [ Obsolete ( "Use EnsureIndex instead." ) ]
176
177
public virtual WriteConcernResult CreateIndex ( IMongoIndexKeys keys , IMongoIndexOptions options )
177
178
{
178
179
var keysDocument = keys . ToBsonDocument ( ) ;
@@ -200,6 +201,7 @@ public virtual WriteConcernResult CreateIndex(IMongoIndexKeys keys, IMongoIndexO
200
201
/// </summary>
201
202
/// <param name="keys">The indexed fields (usually an IndexKeysDocument or constructed using the IndexKeys builder).</param>
202
203
/// <returns>A WriteConcernResult.</returns>
204
+ [ Obsolete ( "Use EnsureIndex instead." ) ]
203
205
public virtual WriteConcernResult CreateIndex ( IMongoIndexKeys keys )
204
206
{
205
207
return CreateIndex ( keys , IndexOptions . Null ) ;
@@ -210,6 +212,7 @@ public virtual WriteConcernResult CreateIndex(IMongoIndexKeys keys)
210
212
/// </summary>
211
213
/// <param name="keyNames">The names of the indexed fields.</param>
212
214
/// <returns>A WriteConcernResult.</returns>
215
+ [ Obsolete ( "Use EnsureIndex instead." ) ]
213
216
public virtual WriteConcernResult CreateIndex ( params string [ ] keyNames )
214
217
{
215
218
return CreateIndex ( IndexKeys . Ascending ( keyNames ) ) ;
@@ -307,15 +310,6 @@ public virtual CommandResult DropIndex(params string[] keyNames)
307
310
/// <returns>A <see cref="CommandResult"/>.</returns>
308
311
public virtual CommandResult DropIndexByName ( string indexName )
309
312
{
310
- // remove from cache first (even if command ends up failing)
311
- if ( indexName == "*" )
312
- {
313
- _server . IndexCache . Reset ( this ) ;
314
- }
315
- else
316
- {
317
- _server . IndexCache . Remove ( this , indexName ) ;
318
- }
319
313
var command = new CommandDocument
320
314
{
321
315
{ "deleteIndexes" , _name } , // not FullName
@@ -342,14 +336,9 @@ public virtual CommandResult DropIndexByName(string indexName)
342
336
/// <param name="options">The index options(usually an IndexOptionsDocument or created using the IndexOption builder).</param>
343
337
public virtual void EnsureIndex ( IMongoIndexKeys keys , IMongoIndexOptions options )
344
338
{
345
- var keysDocument = keys . ToBsonDocument ( ) ;
346
- var optionsDocument = options . ToBsonDocument ( ) ;
347
- var indexName = GetIndexName ( keysDocument , optionsDocument ) ;
348
- if ( ! _server . IndexCache . Contains ( this , indexName ) )
349
- {
350
- CreateIndex ( keys , options ) ;
351
- _server . IndexCache . Add ( this , indexName ) ;
352
- }
339
+ #pragma warning disable 618
340
+ CreateIndex ( keys , options ) ;
341
+ #pragma warning restore
353
342
}
354
343
355
344
/// <summary>
@@ -358,7 +347,9 @@ public virtual void EnsureIndex(IMongoIndexKeys keys, IMongoIndexOptions options
358
347
/// <param name="keys">The indexed fields (usually an IndexKeysDocument or constructed using the IndexKeys builder).</param>
359
348
public virtual void EnsureIndex ( IMongoIndexKeys keys )
360
349
{
361
- EnsureIndex ( keys , IndexOptions . Null ) ;
350
+ #pragma warning disable 618
351
+ CreateIndex ( keys ) ;
352
+ #pragma warning restore
362
353
}
363
354
364
355
/// <summary>
@@ -367,12 +358,9 @@ public virtual void EnsureIndex(IMongoIndexKeys keys)
367
358
/// <param name="keyNames">The names of the indexed fields.</param>
368
359
public virtual void EnsureIndex ( params string [ ] keyNames )
369
360
{
370
- string indexName = GetIndexName ( keyNames ) ;
371
- if ( ! _server . IndexCache . Contains ( this , indexName ) )
372
- {
373
- CreateIndex ( IndexKeys . Ascending ( keyNames ) , IndexOptions . SetName ( indexName ) ) ;
374
- _server . IndexCache . Add ( this , indexName ) ;
375
- }
361
+ #pragma warning disable 618
362
+ CreateIndex ( keyNames ) ;
363
+ #pragma warning restore
376
364
}
377
365
378
366
/// <summary>
@@ -1343,16 +1331,6 @@ public virtual WriteConcernResult RemoveAll(WriteConcern writeConcern)
1343
1331
return Remove ( Query . Null , RemoveFlags . None , writeConcern ) ;
1344
1332
}
1345
1333
1346
- /// <summary>
1347
- /// Removes all entries for this collection in the index cache used by EnsureIndex. Call this method
1348
- /// when you know (or suspect) that a process other than this one may have dropped one or
1349
- /// more indexes.
1350
- /// </summary>
1351
- public virtual void ResetIndexCache ( )
1352
- {
1353
- _server . IndexCache . Reset ( this ) ;
1354
- }
1355
-
1356
1334
/// <summary>
1357
1335
/// Saves a document to this collection. The document must have an identifiable Id field. Based on the value
1358
1336
/// of the Id field Save will perform either an Insert or an Update.
0 commit comments