Пример #1
0
        /// <summary>Or操作</summary>
        /// <param name="exp"></param>
        /// <returns></returns>
        public WhereExpression Or(Expression exp)
        {
            if (exp != null)
            {
                Exps.Add(new ExpItem(false, exp));
            }

            return(this);
        }
Пример #2
0
        /// <summary>And操作</summary>
        /// <param name="exp"></param>
        /// <returns></returns>
        public WhereExpression And(Expression exp)
        {
            if (exp == null)
            {
                return(this);
            }

            // 如果前面有Or,则整体推入下一层
            if (Exps.Any(e => !e.IsAnd))
            {
                var where = new WhereExpression();
                where.Exps.AddRange(Exps);

                Exps.Clear();
                Exps.Add(new ExpItem(true, where));
            }

            Exps.Add(new ExpItem(true, exp));

            return(this);
        }