Exemplo n.º 1
0
        /// <summary>
        /// Applies a <see cref="ExpressionFilter"/> to filter the result.
        /// </summary>
        public FactQuery <T> Filter(ExpressionFilter condition)
        {
            if (_top != null || _skip != null)
            {
                // Programmer mistake
                throw new InvalidOperationException($"Cannot filter the query again after either {nameof(Skip)} or {nameof(Top)} have been invoked.");
            }

            var clone = Clone();

            if (condition != null)
            {
                if (clone._filter == null)
                {
                    clone._filter = condition;
                }
                else
                {
                    clone._filter = ExpressionFilter.Conjunction(clone._filter, condition);
                }
            }

            return(clone);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Applies a <see cref="ExpressionFilter"/> to filter the output.
        /// </summary>
        public AggregateQuery <T> Filter(ExpressionFilter condition)
        {
            if (_top != null)
            {
                // Programmer mistake
                throw new InvalidOperationException($"Cannot filter the query after {nameof(Top)} has been invoked");
            }

            var clone = Clone();

            if (condition != null)
            {
                if (clone._filter == null)
                {
                    clone._filter = condition;
                }
                else
                {
                    clone._filter = ExpressionFilter.Conjunction(clone._filter, condition);
                }
            }

            return(clone);
        }