Пример #1
0
        /// <summary>
        /// Reduce an <see cref="OrCriteria" /> that might contain a <see cref="ConstantCriteria" />.
        /// </summary>
        /// <param name="orCriteria"><see cref="OrCriteria" /> to be reduced.</param>
        /// <returns>Reduced criteria.</returns>
        /// <remarks>
        /// Falses will be removed, trues will replace the entire Or with a true.
        /// </remarks>
        static ICriteria Reduce(OrCriteria orCriteria)
        {
            if (orCriteria.Criteria.Any(c => c == ConstantCriteria.True))
            {
                return(ConstantCriteria.True);
            }

            return(OrCriteria
                   .Combine(orCriteria
                            .Criteria
                            .Select(Reduce)
                            .Where(c => c != ConstantCriteria.False && c != null)
                            .ToArray()));
        }