示例#1
0
        /// <inheritdoc />
        public override MongoDbFilterDefinition HandleOperation(
            MongoDbFilterVisitorContext context,
            IFilterOperationField field,
            IValueNode value,
            object?parsedValue)
        {
            var doc = new MongoDbFilterOperation("$eq", parsedValue);

            return(new MongoDbFilterOperation(context.GetMongoFilterScope().GetPath(), doc));
        }
示例#2
0
        public override MongoDbFilterDefinition HandleOperation(
            MongoDbFilterVisitorContext context,
            IFilterOperationField field,
            IValueNode value,
            object?parsedValue)
        {
            if (parsedValue is string str)
            {
                var doc = new MongoDbFilterOperation(
                    "$regex",
                    new BsonRegularExpression($"/^{Regex.Escape(str)}/"));

                return(new MongoDbFilterOperation(context.GetMongoFilterScope().GetPath(), doc));
            }

            throw new InvalidOperationException();
        }
示例#3
0
 /// <summary>
 /// Tries to build the query based on the items that are stored on the scope
 /// </summary>
 /// <param name="context">the context</param>
 /// <param name="query">The query that was build</param>
 /// <returns>True in case the query has been build successfully, otherwise false</returns>
 public static bool TryCreateQuery(
     this MongoDbFilterVisitorContext context,
     [NotNullWhen(true)] out MongoDbFilterDefinition?query)
 {
     return(context.GetMongoFilterScope().TryCreateQuery(out query));
 }