AggregateBucketAutoResult.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* Copyright 2016-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 MongoDB.Bson.Serialization.Attributes;
  16. namespace MongoDB.Driver
  17. {
  18. /// <summary>
  19. /// Represents the result of the $bucketAuto stage.
  20. /// </summary>
  21. /// <typeparam name="TValue">The type of the value.</typeparam>
  22. public class AggregateBucketAutoResult<TValue>
  23. {
  24. // constructors
  25. /// <summary>
  26. /// Initializes a new instance of the <see cref="AggregateBucketResult{TValue}"/> class.
  27. /// </summary>
  28. /// <param name="id">The inclusive lower boundary of the bucket.</param>
  29. /// <param name="count">The count.</param>
  30. public AggregateBucketAutoResult(AggregateBucketAutoResultId<TValue> id, long count)
  31. {
  32. Id = id;
  33. Count = count;
  34. }
  35. /// <summary>
  36. /// Initializes a new instance of the <see cref="AggregateBucketResult{TValue}" /> class.
  37. /// </summary>
  38. /// <param name="min">The minimum.</param>
  39. /// <param name="max">The maximum.</param>
  40. /// <param name="count">The count.</param>
  41. public AggregateBucketAutoResult(TValue min, TValue max, long count)
  42. {
  43. Id = new AggregateBucketAutoResultId<TValue>(min, max);
  44. Count = count;
  45. }
  46. // public properties
  47. /// <summary>
  48. /// Gets the inclusive lower boundary of the bucket.
  49. /// </summary>
  50. /// <value>
  51. /// The inclusive lower boundary of the bucket.
  52. /// </value>
  53. [BsonId]
  54. public AggregateBucketAutoResultId<TValue> Id { get; private set; }
  55. /// <summary>
  56. /// Gets the count.
  57. /// </summary>
  58. /// <value>
  59. /// The count.
  60. /// </value>
  61. [BsonElement("count")]
  62. public long Count { get; private set; }
  63. /// <summary>
  64. /// Gets the maximum.
  65. /// </summary>
  66. public TValue Max => Id.Max;
  67. /// <summary>
  68. /// Gets the minimum.
  69. /// </summary>
  70. public TValue Min => Id.Min;
  71. }
  72. }