Exemplo n.º 1
0
        /// <summary>
        /// Combine an "and" compound filter with the two filters
        /// </summary>
        /// <param name="filter"></param>
        /// <param name="fragments"></param>
        /// <returns></returns>
        public static ISqlFragment CombineAnd(this ISqlFragment filter, ISqlFragment other)
        {
            if (filter is CompoundWhereFragment c && c.Separator.EqualsIgnoreCase("and"))
            {
                c.Add(other);
                return(c);
            }

            return(CompoundWhereFragment.And(filter, other));
        }
Exemplo n.º 2
0
        /// <summary>
        /// If extras has any items, return an "and" compound fragment. Otherwise return the original filter
        /// </summary>
        /// <param name="filter"></param>
        /// <param name="fragments"></param>
        /// <returns></returns>
        public static ISqlFragment CombineAnd(this ISqlFragment filter, IReadOnlyList <ISqlFragment> extras)
        {
            if (extras.Any())
            {
                if (filter is CompoundWhereFragment c && c.Separator.EqualsIgnoreCase("and"))
                {
                    c.Add(extras);
                    return(c);
                }

                var compound = CompoundWhereFragment.And(extras);
                compound.Add(filter);

                return(compound);
            }

            return(filter);
        }