IMongoCollection.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. /* Copyright 2010-2016 MongoDB Inc.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. using System;
  16. using System.Collections.Generic;
  17. using System.Threading;
  18. using System.Threading.Tasks;
  19. using MongoDB.Bson;
  20. using MongoDB.Bson.Serialization;
  21. namespace MongoDB.Driver
  22. {
  23. /// <summary>
  24. /// Represents a typed collection in MongoDB.
  25. /// </summary>
  26. /// <remarks>
  27. /// This interface is not guaranteed to remain stable. Implementors should use
  28. /// <see cref="MongoCollectionBase{TDocument}"/>.
  29. /// </remarks>
  30. /// <typeparam name="TDocument">The type of the documents stored in the collection.</typeparam>
  31. public interface IMongoCollection<TDocument>
  32. {
  33. /// <summary>
  34. /// Gets the namespace of the collection.
  35. /// </summary>
  36. CollectionNamespace CollectionNamespace { get; }
  37. /// <summary>
  38. /// Gets the database.
  39. /// </summary>
  40. IMongoDatabase Database { get; }
  41. /// <summary>
  42. /// Gets the document serializer.
  43. /// </summary>
  44. IBsonSerializer<TDocument> DocumentSerializer { get; }
  45. /// <summary>
  46. /// Gets the index manager.
  47. /// </summary>
  48. IMongoIndexManager<TDocument> Indexes { get; }
  49. /// <summary>
  50. /// Gets the settings.
  51. /// </summary>
  52. MongoCollectionSettings Settings { get; }
  53. /// <summary>
  54. /// Runs an aggregation pipeline.
  55. /// </summary>
  56. /// <typeparam name="TResult">The type of the result.</typeparam>
  57. /// <param name="pipeline">The pipeline.</param>
  58. /// <param name="options">The options.</param>
  59. /// <param name="cancellationToken">The cancellation token.</param>
  60. /// <returns>A cursor.</returns>
  61. IAsyncCursor<TResult> Aggregate<TResult>(PipelineDefinition<TDocument, TResult> pipeline, AggregateOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
  62. /// <summary>
  63. /// Runs an aggregation pipeline.
  64. /// </summary>
  65. /// <typeparam name="TResult">The type of the result.</typeparam>
  66. /// <param name="pipeline">The pipeline.</param>
  67. /// <param name="options">The options.</param>
  68. /// <param name="cancellationToken">The cancellation token.</param>
  69. /// <returns>A Task whose result is a cursor.</returns>
  70. Task<IAsyncCursor<TResult>> AggregateAsync<TResult>(PipelineDefinition<TDocument, TResult> pipeline, AggregateOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
  71. /// <summary>
  72. /// Performs multiple write operations.
  73. /// </summary>
  74. /// <param name="requests">The requests.</param>
  75. /// <param name="options">The options.</param>
  76. /// <param name="cancellationToken">The cancellation token.</param>
  77. /// <returns>The result of writing.</returns>
  78. BulkWriteResult<TDocument> BulkWrite(IEnumerable<WriteModel<TDocument>> requests, BulkWriteOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
  79. /// <summary>
  80. /// Performs multiple write operations.
  81. /// </summary>
  82. /// <param name="requests">The requests.</param>
  83. /// <param name="options">The options.</param>
  84. /// <param name="cancellationToken">The cancellation token.</param>
  85. /// <returns>The result of writing.</returns>
  86. Task<BulkWriteResult<TDocument>> BulkWriteAsync(IEnumerable<WriteModel<TDocument>> requests, BulkWriteOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
  87. /// <summary>
  88. /// Counts the number of documents in the collection.
  89. /// </summary>
  90. /// <param name="filter">The filter.</param>
  91. /// <param name="options">The options.</param>
  92. /// <param name="cancellationToken">The cancellation token.</param>
  93. /// <returns>
  94. /// The number of documents in the collection.
  95. /// </returns>
  96. long Count(FilterDefinition<TDocument> filter, CountOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
  97. /// <summary>
  98. /// Counts the number of documents in the collection.
  99. /// </summary>
  100. /// <param name="filter">The filter.</param>
  101. /// <param name="options">The options.</param>
  102. /// <param name="cancellationToken">The cancellation token.</param>
  103. /// <returns>
  104. /// The number of documents in the collection.
  105. /// </returns>
  106. Task<long> CountAsync(FilterDefinition<TDocument> filter, CountOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
  107. /// <summary>
  108. /// Deletes multiple documents.
  109. /// </summary>
  110. /// <param name="filter">The filter.</param>
  111. /// <param name="cancellationToken">The cancellation token.</param>
  112. /// <returns>
  113. /// The result of the delete operation.
  114. /// </returns>
  115. DeleteResult DeleteMany(FilterDefinition<TDocument> filter, CancellationToken cancellationToken = default(CancellationToken));
  116. /// <summary>
  117. /// Deletes multiple documents.
  118. /// </summary>
  119. /// <param name="filter">The filter.</param>
  120. /// <param name="options">The options.</param>
  121. /// <param name="cancellationToken">The cancellation token.</param>
  122. /// <returns>
  123. /// The result of the delete operation.
  124. /// </returns>
  125. DeleteResult DeleteMany(FilterDefinition<TDocument> filter, DeleteOptions options, CancellationToken cancellationToken = default(CancellationToken));
  126. /// <summary>
  127. /// Deletes multiple documents.
  128. /// </summary>
  129. /// <param name="filter">The filter.</param>
  130. /// <param name="cancellationToken">The cancellation token.</param>
  131. /// <returns>
  132. /// The result of the delete operation.
  133. /// </returns>
  134. Task<DeleteResult> DeleteManyAsync(FilterDefinition<TDocument> filter, CancellationToken cancellationToken = default(CancellationToken));
  135. /// <summary>
  136. /// Deletes multiple documents.
  137. /// </summary>
  138. /// <param name="filter">The filter.</param>
  139. /// <param name="options">The options.</param>
  140. /// <param name="cancellationToken">The cancellation token.</param>
  141. /// <returns>
  142. /// The result of the delete operation.
  143. /// </returns>
  144. Task<DeleteResult> DeleteManyAsync(FilterDefinition<TDocument> filter, DeleteOptions options, CancellationToken cancellationToken = default(CancellationToken));
  145. /// <summary>
  146. /// Deletes a single document.
  147. /// </summary>
  148. /// <param name="filter">The filter.</param>
  149. /// <param name="cancellationToken">The cancellation token.</param>
  150. /// <returns>
  151. /// The result of the delete operation.
  152. /// </returns>
  153. DeleteResult DeleteOne(FilterDefinition<TDocument> filter, CancellationToken cancellationToken = default(CancellationToken));
  154. /// <summary>
  155. /// Deletes a single document.
  156. /// </summary>
  157. /// <param name="filter">The filter.</param>
  158. /// <param name="options">The options.</param>
  159. /// <param name="cancellationToken">The cancellation token.</param>
  160. /// <returns>
  161. /// The result of the delete operation.
  162. /// </returns>
  163. DeleteResult DeleteOne(FilterDefinition<TDocument> filter, DeleteOptions options, CancellationToken cancellationToken = default(CancellationToken));
  164. /// <summary>
  165. /// Deletes a single document.
  166. /// </summary>
  167. /// <param name="filter">The filter.</param>
  168. /// <param name="cancellationToken">The cancellation token.</param>
  169. /// <returns>
  170. /// The result of the delete operation.
  171. /// </returns>
  172. Task<DeleteResult> DeleteOneAsync(FilterDefinition<TDocument> filter, CancellationToken cancellationToken = default(CancellationToken));
  173. /// <summary>
  174. /// Deletes a single document.
  175. /// </summary>
  176. /// <param name="filter">The filter.</param>
  177. /// <param name="options">The options.</param>
  178. /// <param name="cancellationToken">The cancellation token.</param>
  179. /// <returns>
  180. /// The result of the delete operation.
  181. /// </returns>
  182. Task<DeleteResult> DeleteOneAsync(FilterDefinition<TDocument> filter, DeleteOptions options, CancellationToken cancellationToken = default(CancellationToken));
  183. /// <summary>
  184. /// Gets the distinct values for a specified field.
  185. /// </summary>
  186. /// <typeparam name="TField">The type of the result.</typeparam>
  187. /// <param name="field">The field.</param>
  188. /// <param name="filter">The filter.</param>
  189. /// <param name="options">The options.</param>
  190. /// <param name="cancellationToken">The cancellation token.</param>
  191. /// <returns>A cursor.</returns>
  192. IAsyncCursor<TField> Distinct<TField>(FieldDefinition<TDocument, TField> field, FilterDefinition<TDocument> filter, DistinctOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
  193. /// <summary>
  194. /// Gets the distinct values for a specified field.
  195. /// </summary>
  196. /// <typeparam name="TField">The type of the result.</typeparam>
  197. /// <param name="field">The field.</param>
  198. /// <param name="filter">The filter.</param>
  199. /// <param name="options">The options.</param>
  200. /// <param name="cancellationToken">The cancellation token.</param>
  201. /// <returns>A Task whose result is a cursor.</returns>
  202. Task<IAsyncCursor<TField>> DistinctAsync<TField>(FieldDefinition<TDocument, TField> field, FilterDefinition<TDocument> filter, DistinctOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
  203. /// <summary>
  204. /// Finds the documents matching the filter.
  205. /// </summary>
  206. /// <typeparam name="TProjection">The type of the projection (same as TDocument if there is no projection).</typeparam>
  207. /// <param name="filter">The filter.</param>
  208. /// <param name="options">The options.</param>
  209. /// <param name="cancellationToken">The cancellation token.</param>
  210. /// <returns>A cursor.</returns>
  211. IAsyncCursor<TProjection> FindSync<TProjection>(FilterDefinition<TDocument> filter, FindOptions<TDocument, TProjection> options = null, CancellationToken cancellationToken = default(CancellationToken));
  212. /// <summary>
  213. /// Finds the documents matching the filter.
  214. /// </summary>
  215. /// <typeparam name="TProjection">The type of the projection (same as TDocument if there is no projection).</typeparam>
  216. /// <param name="filter">The filter.</param>
  217. /// <param name="options">The options.</param>
  218. /// <param name="cancellationToken">The cancellation token.</param>
  219. /// <returns>A Task whose result is a cursor.</returns>
  220. Task<IAsyncCursor<TProjection>> FindAsync<TProjection>(FilterDefinition<TDocument> filter, FindOptions<TDocument, TProjection> options = null, CancellationToken cancellationToken = default(CancellationToken));
  221. /// <summary>
  222. /// Finds a single document and deletes it atomically.
  223. /// </summary>
  224. /// <typeparam name="TProjection">The type of the projection (same as TDocument if there is no projection).</typeparam>
  225. /// <param name="filter">The filter.</param>
  226. /// <param name="options">The options.</param>
  227. /// <param name="cancellationToken">The cancellation token.</param>
  228. /// <returns>
  229. /// The returned document.
  230. /// </returns>
  231. TProjection FindOneAndDelete<TProjection>(FilterDefinition<TDocument> filter, FindOneAndDeleteOptions<TDocument, TProjection> options = null, CancellationToken cancellationToken = default(CancellationToken));
  232. /// <summary>
  233. /// Finds a single document and deletes it atomically.
  234. /// </summary>
  235. /// <typeparam name="TProjection">The type of the projection (same as TDocument if there is no projection).</typeparam>
  236. /// <param name="filter">The filter.</param>
  237. /// <param name="options">The options.</param>
  238. /// <param name="cancellationToken">The cancellation token.</param>
  239. /// <returns>
  240. /// The returned document.
  241. /// </returns>
  242. Task<TProjection> FindOneAndDeleteAsync<TProjection>(FilterDefinition<TDocument> filter, FindOneAndDeleteOptions<TDocument, TProjection> options = null, CancellationToken cancellationToken = default(CancellationToken));
  243. /// <summary>
  244. /// Finds a single document and replaces it atomically.
  245. /// </summary>
  246. /// <typeparam name="TProjection">The type of the projection (same as TDocument if there is no projection).</typeparam>
  247. /// <param name="filter">The filter.</param>
  248. /// <param name="replacement">The replacement.</param>
  249. /// <param name="options">The options.</param>
  250. /// <param name="cancellationToken">The cancellation token.</param>
  251. /// <returns>
  252. /// The returned document.
  253. /// </returns>
  254. TProjection FindOneAndReplace<TProjection>(FilterDefinition<TDocument> filter, TDocument replacement, FindOneAndReplaceOptions<TDocument, TProjection> options = null, CancellationToken cancellationToken = default(CancellationToken));
  255. /// <summary>
  256. /// Finds a single document and replaces it atomically.
  257. /// </summary>
  258. /// <typeparam name="TProjection">The type of the projection (same as TDocument if there is no projection).</typeparam>
  259. /// <param name="filter">The filter.</param>
  260. /// <param name="replacement">The replacement.</param>
  261. /// <param name="options">The options.</param>
  262. /// <param name="cancellationToken">The cancellation token.</param>
  263. /// <returns>
  264. /// The returned document.
  265. /// </returns>
  266. Task<TProjection> FindOneAndReplaceAsync<TProjection>(FilterDefinition<TDocument> filter, TDocument replacement, FindOneAndReplaceOptions<TDocument, TProjection> options = null, CancellationToken cancellationToken = default(CancellationToken));
  267. /// <summary>
  268. /// Finds a single document and updates it atomically.
  269. /// </summary>
  270. /// <typeparam name="TProjection">The type of the projection (same as TDocument if there is no projection).</typeparam>
  271. /// <param name="filter">The filter.</param>
  272. /// <param name="update">The update.</param>
  273. /// <param name="options">The options.</param>
  274. /// <param name="cancellationToken">The cancellation token.</param>
  275. /// <returns>
  276. /// The returned document.
  277. /// </returns>
  278. TProjection FindOneAndUpdate<TProjection>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> update, FindOneAndUpdateOptions<TDocument, TProjection> options = null, CancellationToken cancellationToken = default(CancellationToken));
  279. /// <summary>
  280. /// Finds a single document and updates it atomically.
  281. /// </summary>
  282. /// <typeparam name="TProjection">The type of the projection (same as TDocument if there is no projection).</typeparam>
  283. /// <param name="filter">The filter.</param>
  284. /// <param name="update">The update.</param>
  285. /// <param name="options">The options.</param>
  286. /// <param name="cancellationToken">The cancellation token.</param>
  287. /// <returns>
  288. /// The returned document.
  289. /// </returns>
  290. Task<TProjection> FindOneAndUpdateAsync<TProjection>(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> update, FindOneAndUpdateOptions<TDocument, TProjection> options = null, CancellationToken cancellationToken = default(CancellationToken));
  291. /// <summary>
  292. /// Inserts a single document.
  293. /// </summary>
  294. /// <param name="document">The document.</param>
  295. /// <param name="options">The options.</param>
  296. /// <param name="cancellationToken">The cancellation token.</param>
  297. void InsertOne(TDocument document, InsertOneOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
  298. /// <summary>
  299. /// Inserts a single document.
  300. /// </summary>
  301. /// <param name="document">The document.</param>
  302. /// <param name="_cancellationToken">The cancellation token.</param>
  303. /// <returns>
  304. /// The result of the insert operation.
  305. /// </returns>
  306. [Obsolete("Use the new overload of InsertOneAsync with an InsertOneOptions parameter instead.")]
  307. Task InsertOneAsync(TDocument document, CancellationToken _cancellationToken);
  308. /// <summary>
  309. /// Inserts a single document.
  310. /// </summary>
  311. /// <param name="document">The document.</param>
  312. /// <param name="options">The options.</param>
  313. /// <param name="cancellationToken">The cancellation token.</param>
  314. /// <returns>
  315. /// The result of the insert operation.
  316. /// </returns>
  317. Task InsertOneAsync(TDocument document, InsertOneOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
  318. /// <summary>
  319. /// Inserts many documents.
  320. /// </summary>
  321. /// <param name="documents">The documents.</param>
  322. /// <param name="options">The options.</param>
  323. /// <param name="cancellationToken">The cancellation token.</param>
  324. void InsertMany(IEnumerable<TDocument> documents, InsertManyOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
  325. /// <summary>
  326. /// Inserts many documents.
  327. /// </summary>
  328. /// <param name="documents">The documents.</param>
  329. /// <param name="options">The options.</param>
  330. /// <param name="cancellationToken">The cancellation token.</param>
  331. /// <returns>
  332. /// The result of the insert operation.
  333. /// </returns>
  334. Task InsertManyAsync(IEnumerable<TDocument> documents, InsertManyOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
  335. /// <summary>
  336. /// Executes a map-reduce command.
  337. /// </summary>
  338. /// <typeparam name="TResult">The type of the result.</typeparam>
  339. /// <param name="map">The map function.</param>
  340. /// <param name="reduce">The reduce function.</param>
  341. /// <param name="options">The options.</param>
  342. /// <param name="cancellationToken">The cancellation token.</param>
  343. /// <returns>A cursor.</returns>
  344. IAsyncCursor<TResult> MapReduce<TResult>(BsonJavaScript map, BsonJavaScript reduce, MapReduceOptions<TDocument, TResult> options = null, CancellationToken cancellationToken = default(CancellationToken));
  345. /// <summary>
  346. /// Executes a map-reduce command.
  347. /// </summary>
  348. /// <typeparam name="TResult">The type of the result.</typeparam>
  349. /// <param name="map">The map function.</param>
  350. /// <param name="reduce">The reduce function.</param>
  351. /// <param name="options">The options.</param>
  352. /// <param name="cancellationToken">The cancellation token.</param>
  353. /// <returns>A Task whose result is a cursor.</returns>
  354. Task<IAsyncCursor<TResult>> MapReduceAsync<TResult>(BsonJavaScript map, BsonJavaScript reduce, MapReduceOptions<TDocument, TResult> options = null, CancellationToken cancellationToken = default(CancellationToken));
  355. /// <summary>
  356. /// Returns a filtered collection that appears to contain only documents of the derived type.
  357. /// All operations using this filtered collection will automatically use discriminators as necessary.
  358. /// </summary>
  359. /// <typeparam name="TDerivedDocument">The type of the derived document.</typeparam>
  360. /// <returns>A filtered collection.</returns>
  361. IFilteredMongoCollection<TDerivedDocument> OfType<TDerivedDocument>() where TDerivedDocument : TDocument;
  362. /// <summary>
  363. /// Replaces a single document.
  364. /// </summary>
  365. /// <param name="filter">The filter.</param>
  366. /// <param name="replacement">The replacement.</param>
  367. /// <param name="options">The options.</param>
  368. /// <param name="cancellationToken">The cancellation token.</param>
  369. /// <returns>
  370. /// The result of the replacement.
  371. /// </returns>
  372. ReplaceOneResult ReplaceOne(FilterDefinition<TDocument> filter, TDocument replacement, UpdateOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
  373. /// <summary>
  374. /// Replaces a single document.
  375. /// </summary>
  376. /// <param name="filter">The filter.</param>
  377. /// <param name="replacement">The replacement.</param>
  378. /// <param name="options">The options.</param>
  379. /// <param name="cancellationToken">The cancellation token.</param>
  380. /// <returns>
  381. /// The result of the replacement.
  382. /// </returns>
  383. Task<ReplaceOneResult> ReplaceOneAsync(FilterDefinition<TDocument> filter, TDocument replacement, UpdateOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
  384. /// <summary>
  385. /// Updates many documents.
  386. /// </summary>
  387. /// <param name="filter">The filter.</param>
  388. /// <param name="update">The update.</param>
  389. /// <param name="options">The options.</param>
  390. /// <param name="cancellationToken">The cancellation token.</param>
  391. /// <returns>
  392. /// The result of the update operation.
  393. /// </returns>
  394. UpdateResult UpdateMany(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> update, UpdateOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
  395. /// <summary>
  396. /// Updates many documents.
  397. /// </summary>
  398. /// <param name="filter">The filter.</param>
  399. /// <param name="update">The update.</param>
  400. /// <param name="options">The options.</param>
  401. /// <param name="cancellationToken">The cancellation token.</param>
  402. /// <returns>
  403. /// The result of the update operation.
  404. /// </returns>
  405. Task<UpdateResult> UpdateManyAsync(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> update, UpdateOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
  406. /// <summary>
  407. /// Updates a single document.
  408. /// </summary>
  409. /// <param name="filter">The filter.</param>
  410. /// <param name="update">The update.</param>
  411. /// <param name="options">The options.</param>
  412. /// <param name="cancellationToken">The cancellation token.</param>
  413. /// <returns>
  414. /// The result of the update operation.
  415. /// </returns>
  416. UpdateResult UpdateOne(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> update, UpdateOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
  417. /// <summary>
  418. /// Updates a single document.
  419. /// </summary>
  420. /// <param name="filter">The filter.</param>
  421. /// <param name="update">The update.</param>
  422. /// <param name="options">The options.</param>
  423. /// <param name="cancellationToken">The cancellation token.</param>
  424. /// <returns>
  425. /// The result of the update operation.
  426. /// </returns>
  427. Task<UpdateResult> UpdateOneAsync(FilterDefinition<TDocument> filter, UpdateDefinition<TDocument> update, UpdateOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
  428. /// <summary>
  429. /// Returns a new IMongoCollection instance with a different read concern setting.
  430. /// </summary>
  431. /// <param name="readConcern">The read concern.</param>
  432. /// <returns>A new IMongoCollection instance with a different read concern setting.</returns>
  433. IMongoCollection<TDocument> WithReadConcern(ReadConcern readConcern);
  434. /// <summary>
  435. /// Returns a new IMongoCollection instance with a different read preference setting.
  436. /// </summary>
  437. /// <param name="readPreference">The read preference.</param>
  438. /// <returns>A new IMongoCollection instance with a different read preference setting.</returns>
  439. IMongoCollection<TDocument> WithReadPreference(ReadPreference readPreference);
  440. /// <summary>
  441. /// Returns a new IMongoCollection instance with a different write concern setting.
  442. /// </summary>
  443. /// <param name="writeConcern">The write concern.</param>
  444. /// <returns>A new IMongoCollection instance with a different write concern setting.</returns>
  445. IMongoCollection<TDocument> WithWriteConcern(WriteConcern writeConcern);
  446. }
  447. }