IFindFluent.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* Copyright 2010-2015 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.Threading;
  16. using System.Threading.Tasks;
  17. using MongoDB.Bson.Serialization;
  18. namespace MongoDB.Driver
  19. {
  20. /// <summary>
  21. /// Fluent interface for find.
  22. /// </summary>
  23. /// <remarks>
  24. /// This interface is not guaranteed to remain stable. Implementors should use
  25. /// <see cref="FindFluentBase{TDocument, TProjection}" />.
  26. /// </remarks>
  27. /// <typeparam name="TDocument">The type of the document.</typeparam>
  28. /// <typeparam name="TProjection">The type of the projection (same as TDocument if there is no projection).</typeparam>
  29. public interface IFindFluent<TDocument, TProjection> : IAsyncCursorSource<TProjection>
  30. {
  31. /// <summary>
  32. /// Gets or sets the filter.
  33. /// </summary>
  34. FilterDefinition<TDocument> Filter { get; set; }
  35. /// <summary>
  36. /// Gets the options.
  37. /// </summary>
  38. FindOptions<TDocument, TProjection> Options { get; }
  39. /// <summary>
  40. /// A simplified type of projection that changes the result type by using a different serializer.
  41. /// </summary>
  42. /// <typeparam name="TResult">The type of the result.</typeparam>
  43. /// <param name="resultSerializer">The result serializer.</param>
  44. /// <returns>The fluent find interface.</returns>
  45. IFindFluent<TDocument, TResult> As<TResult>(IBsonSerializer<TResult> resultSerializer = null);
  46. /// <summary>
  47. /// Counts the number of documents.
  48. /// </summary>
  49. /// <param name="cancellationToken">The cancellation token.</param>
  50. /// <returns>The count.</returns>
  51. long Count(CancellationToken cancellationToken = default(CancellationToken));
  52. /// <summary>
  53. /// Counts the number of documents.
  54. /// </summary>
  55. /// <param name="cancellationToken">The cancellation token.</param>
  56. /// <returns>A Task whose result is the count.</returns>
  57. Task<long> CountAsync(CancellationToken cancellationToken = default(CancellationToken));
  58. /// <summary>
  59. /// Limits the number of documents.
  60. /// </summary>
  61. /// <param name="limit">The limit.</param>
  62. /// <returns>The fluent find interface.</returns>
  63. IFindFluent<TDocument, TProjection> Limit(int? limit);
  64. /// <summary>
  65. /// Projects the the result.
  66. /// </summary>
  67. /// <typeparam name="TNewProjection">The type of the projection.</typeparam>
  68. /// <param name="projection">The projection.</param>
  69. /// <returns>The fluent find interface.</returns>
  70. IFindFluent<TDocument, TNewProjection> Project<TNewProjection>(ProjectionDefinition<TDocument, TNewProjection> projection);
  71. /// <summary>
  72. /// Skips the the specified number of documents.
  73. /// </summary>
  74. /// <param name="skip">The skip.</param>
  75. /// <returns>The fluent find interface.</returns>
  76. IFindFluent<TDocument, TProjection> Skip(int? skip);
  77. /// <summary>
  78. /// Sorts the the documents.
  79. /// </summary>
  80. /// <param name="sort">The sort.</param>
  81. /// <returns>The fluent find interface.</returns>
  82. IFindFluent<TDocument, TProjection> Sort(SortDefinition<TDocument> sort);
  83. }
  84. /// <summary>
  85. /// Fluent interface for find.
  86. /// </summary>
  87. /// <typeparam name="TDocument">The type of the document.</typeparam>
  88. /// <typeparam name="TProjection">The type of the projection (same as TDocument if there is no projection).</typeparam>
  89. public interface IOrderedFindFluent<TDocument, TProjection> : IFindFluent<TDocument, TProjection>
  90. {
  91. }
  92. }