FindFluentBase.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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;
  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. public virtual long Count(CancellationToken cancellationToken = default(CancellationToken))
  36. {
  37. throw new NotImplementedException();
  38. }
  39. /// <inheritdoc />
  40. public abstract Task<long> CountAsync(CancellationToken cancellationToken = default(CancellationToken));
  41. /// <inheritdoc />
  42. public abstract IFindFluent<TDocument, TProjection> Limit(int? limit);
  43. /// <inheritdoc />
  44. public abstract IFindFluent<TDocument, TNewProjection> Project<TNewProjection>(ProjectionDefinition<TDocument, TNewProjection> projection);
  45. /// <inheritdoc />
  46. public abstract IFindFluent<TDocument, TProjection> Skip(int? skip);
  47. /// <inheritdoc />
  48. public abstract IFindFluent<TDocument, TProjection> Sort(SortDefinition<TDocument> sort);
  49. /// <inheritdoc />
  50. public virtual IAsyncCursor<TProjection> ToCursor(CancellationToken cancellationToken)
  51. {
  52. throw new NotImplementedException();
  53. }
  54. /// <inheritdoc />
  55. public abstract Task<IAsyncCursor<TProjection>> ToCursorAsync(CancellationToken cancellationToken);
  56. }
  57. }