FindFluentBase.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* Copyright 2010-present 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.Threading;
  17. using System.Threading.Tasks;
  18. using MongoDB.Bson.Serialization;
  19. namespace MongoDB.Driver
  20. {
  21. /// <summary>
  22. /// Base class for implementors of <see cref="IFindFluent{TDocument, TProjection}" />.
  23. /// </summary>
  24. /// <typeparam name="TDocument">The type of the document.</typeparam>
  25. /// <typeparam name="TProjection">The type of the projection (same as TDocument if there is no projection).</typeparam>
  26. public abstract class FindFluentBase<TDocument, TProjection> : IOrderedFindFluent<TDocument, TProjection>
  27. {
  28. /// <inheritdoc />
  29. public abstract FilterDefinition<TDocument> Filter { get; set; }
  30. /// <inheritdoc />
  31. public abstract FindOptions<TDocument, TProjection> Options { get; }
  32. /// <inheritdoc />
  33. public abstract IFindFluent<TDocument, TResult> As<TResult>(IBsonSerializer<TResult> resultSerializer);
  34. /// <inheritdoc />
  35. [Obsolete("Use CountDocuments instead.")]
  36. public virtual long Count(CancellationToken cancellationToken = default(CancellationToken))
  37. {
  38. throw new NotImplementedException();
  39. }
  40. /// <inheritdoc />
  41. [Obsolete("Use CountDocumentsAsync instead.")]
  42. public abstract Task<long> CountAsync(CancellationToken cancellationToken = default(CancellationToken));
  43. /// <inheritdoc />
  44. public virtual long CountDocuments(CancellationToken cancellationToken = default(CancellationToken))
  45. {
  46. throw new NotImplementedException();
  47. }
  48. /// <inheritdoc />
  49. public virtual Task<long> CountDocumentsAsync(CancellationToken cancellationToken = default(CancellationToken))
  50. {
  51. throw new NotImplementedException();
  52. }
  53. /// <inheritdoc />
  54. public abstract IFindFluent<TDocument, TProjection> Limit(int? limit);
  55. /// <inheritdoc />
  56. public abstract IFindFluent<TDocument, TNewProjection> Project<TNewProjection>(ProjectionDefinition<TDocument, TNewProjection> projection);
  57. /// <inheritdoc />
  58. public abstract IFindFluent<TDocument, TProjection> Skip(int? skip);
  59. /// <inheritdoc />
  60. public abstract IFindFluent<TDocument, TProjection> Sort(SortDefinition<TDocument> sort);
  61. /// <inheritdoc />
  62. public virtual IAsyncCursor<TProjection> ToCursor(CancellationToken cancellationToken)
  63. {
  64. throw new NotImplementedException();
  65. }
  66. /// <inheritdoc />
  67. public abstract Task<IAsyncCursor<TProjection>> ToCursorAsync(CancellationToken cancellationToken);
  68. }
  69. }