Esempio n. 1
0
 /// <summary>
 /// Creates a descending sort.
 /// </summary>
 /// <param name="field">The field.</param>
 /// <returns>A descending sort.</returns>
 public SortDefinition <TDocument> Descending(FieldDefinition <TDocument> field)
 {
     return(new DirectionalSortDefinition <TDocument>(field, SortDirection.Descending));
 }
 public WildcardIndexKeyDefinition(FieldDefinition <TDocument> field = null)
 {
     _field = field;
 }
        /// <summary>
        /// Combines an existing index keys definition with a descending index key definition.
        /// </summary>
        /// <typeparam name="TDocument">The type of the document.</typeparam>
        /// <param name="keys">The keys.</param>
        /// <param name="field">The field.</param>
        /// <returns>
        /// A combined index keys definition.
        /// </returns>
        public static IndexKeysDefinition <TDocument> Descending <TDocument>(this IndexKeysDefinition <TDocument> keys, FieldDefinition <TDocument> field)
        {
            var builder = Builders <TDocument> .IndexKeys;

            return(builder.Combine(keys, builder.Descending(field)));
        }
 public GeoHaystackIndexKeyDefinition(FieldDefinition <TDocument> field, FieldDefinition <TDocument> additionalFieldName = null)
 {
     _field = Ensure.IsNotNull(field, nameof(field));
     _additionalFieldName = additionalFieldName;
 }
 public SimpleIndexKeyDefinition(FieldDefinition <TDocument> field, string type)
 {
     _field = Ensure.IsNotNull(field, nameof(field));
     _type  = type;
 }
        public static IndexKeysDefinition <TDocument> GeoHaystack <TDocument>(this IndexKeysDefinition <TDocument> keys, FieldDefinition <TDocument> field, FieldDefinition <TDocument> additionalFieldName = null)
        {
            var builder = Builders <TDocument> .IndexKeys;

            return(builder.Combine(keys, builder.GeoHaystack(field, additionalFieldName)));
        }
 /// <summary>
 /// Creates a wildcard index key definition. The method doesn't expect to specify a wildcard key explicitly.
 /// </summary>
 /// <param name="field">The wildcard key name. If the wildcard name is empty, the generated key will be `All field paths`, otherwise `A single field path`.</param>
 /// <returns>A wildcard index key definition.</returns>
 public IndexKeysDefinition <TDocument> Wildcard(FieldDefinition <TDocument> field = null)
 {
     return(new WildcardIndexKeyDefinition <TDocument>(field));
 }
 /// <summary>
 /// Creates a 2dsphere index key definition.
 /// </summary>
 /// <param name="field">The field.</param>
 /// <returns>A 2dsphere index key definition.</returns>
 public IndexKeysDefinition <TDocument> Geo2DSphere(FieldDefinition <TDocument> field)
 {
     return(new SimpleIndexKeyDefinition <TDocument>(field, "2dsphere"));
 }
 /// <summary>
 /// Creates a hashed index key definition.
 /// </summary>
 /// <param name="field">The field.</param>
 /// <returns>A hashed index key definition.</returns>
 public IndexKeysDefinition <TDocument> Hashed(FieldDefinition <TDocument> field)
 {
     return(new SimpleIndexKeyDefinition <TDocument>(field, "hashed"));
 }
 public IndexKeysDefinition <TDocument> GeoHaystack(FieldDefinition <TDocument> field, FieldDefinition <TDocument> additionalFieldName = null)
 {
     return(new GeoHaystackIndexKeyDefinition <TDocument>(field, additionalFieldName));
 }
        public IndexKeysDefinition <TDocument> GeoHaystack(Expression <Func <TDocument, object> > field, Expression <Func <TDocument, object> > additionalFieldName = null)
        {
            FieldDefinition <TDocument> additional = additionalFieldName == null ? null : new ExpressionFieldDefinition <TDocument>(additionalFieldName);

            return(GeoHaystack(new ExpressionFieldDefinition <TDocument>(field), additional));
        }
 /// <summary>
 /// Creates an ascending index key definition.
 /// </summary>
 /// <param name="field">The field.</param>
 /// <returns>An ascending index key definition.</returns>
 public IndexKeysDefinition <TDocument> Ascending(FieldDefinition <TDocument> field)
 {
     return(new DirectionalIndexKeyDefinition <TDocument>(field, SortDirection.Ascending));
 }
        /// <summary>
        /// Combines an existing index keys definition with a hashed index key definition.
        /// </summary>
        /// <typeparam name="TDocument">The type of the document.</typeparam>
        /// <param name="keys">The keys.</param>
        /// <param name="field">The field.</param>
        /// <returns>
        /// A combined index keys definition.
        /// </returns>
        public static IndexKeysDefinition <TDocument> Hashed <TDocument>(this IndexKeysDefinition <TDocument> keys, FieldDefinition <TDocument> field)
        {
            var builder = Builders <TDocument> .IndexKeys;

            return(builder.Combine(keys, builder.Hashed(field)));
        }
        /// <summary>
        /// Combines an existing index keys definition with a 2dsphere index key definition.
        /// </summary>
        /// <typeparam name="TDocument">The type of the document.</typeparam>
        /// <param name="keys">The keys.</param>
        /// <param name="field">The field.</param>
        /// <returns>
        /// A combined index keys definition.
        /// </returns>
        public static IndexKeysDefinition <TDocument> Geo2DSphere <TDocument>(this IndexKeysDefinition <TDocument> keys, FieldDefinition <TDocument> field)
        {
            var builder = Builders <TDocument> .IndexKeys;

            return(builder.Combine(keys, builder.Geo2DSphere(field)));
        }
Esempio n. 15
0
 public DirectionalSortDefinition(FieldDefinition <TDocument> field, SortDirection direction)
 {
     _field     = Ensure.IsNotNull(field, nameof(field));
     _direction = direction;
 }
 /// <summary>
 /// Creates a text index key definition.
 /// </summary>
 /// <param name="field">The field.</param>
 /// <returns>A text index key definition.</returns>
 public IndexKeysDefinition <TDocument> Text(FieldDefinition <TDocument> field)
 {
     return(new SimpleIndexKeyDefinition <TDocument>(field, "text"));
 }
Esempio n. 17
0
        /// <summary>
        /// Combines an existing sort with an descending field.
        /// </summary>
        /// <typeparam name="TDocument">The type of the document.</typeparam>
        /// <param name="sort">The sort.</param>
        /// <param name="field">The field.</param>
        /// <returns>
        /// A combined sort.
        /// </returns>
        public static SortDefinition <TDocument> Descending <TDocument>(this SortDefinition <TDocument> sort, FieldDefinition <TDocument> field)
        {
            var builder = Builders <TDocument> .Sort;

            return(builder.Combine(sort, builder.Descending(field)));
        }
        /// <summary>
        /// Gets the distinct values for a specified field.
        /// </summary>
        /// <typeparam name="TDocument">The type of the document.</typeparam>
        /// <typeparam name="TField">The type of the result.</typeparam>
        /// <param name="collection">The collection.</param>
        /// <param name="field">The field.</param>
        /// <param name="filter">The filter.</param>
        /// <param name="options">The options.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// The distinct values for the specified field.
        /// </returns>
        public static Task <IAsyncCursor <TField> > DistinctAsync <TDocument, TField>(this IMongoCollection <TDocument> collection, FieldDefinition <TDocument, TField> field, Expression <Func <TDocument, bool> > filter, DistinctOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            Ensure.IsNotNull(collection, "collection");
            Ensure.IsNotNull(field, "field");
            Ensure.IsNotNull(filter, "filter");

            return(collection.DistinctAsync <TField>(
                       field,
                       new ExpressionFilterDefinition <TDocument>(filter),
                       options,
                       cancellationToken));
        }