コード例 #1
0
        /// <summary>
        /// Creates <see cref="OrCondition"/> between left and right <see cref="IList{T}"/>s.
        /// List of conditions in parameters unite inside by <see cref="AndCondition"/>.
        /// </summary>
        /// <param name="leftConditions">conditions which will be created as <see cref="AndCondition"/>.</param>
        /// <param name="rightConditions">conditions which will be created as <see cref="AndCondition"/>.</param>
        public OrCondition(IList<BaseCondition> leftConditions, IList<BaseCondition> rightConditions)
            : this()
        {
            if (leftConditions == null || leftConditions.Count == 0)
            {
                throw new SpoltyException("leftConditions is incorrect");
            }

            if (rightConditions == null)
            {
                throw new SpoltyException("rightConditions is incorrect");
            }

            LeftCondition = new AndCondition(leftConditions);

            if (rightConditions.Count > 0)
            {
                RightCondition = new AndCondition(rightConditions);
            }
        }
コード例 #2
0
        public Expression Make(IEnumerable<BaseCondition> conditions, Expression sourceExpression)
        {
            Checker.CheckArgumentNull(conditions, "conditionals");
            Checker.CheckArgumentNull(sourceExpression, "sourceExpression");

            var condition = new AndCondition(conditions);
            if (condition.LeftCondition == null)
            {
                return sourceExpression;
            }

            Type sourceType = ExpressionHelper.GetGenericType(sourceExpression);
            ParameterExpression parameterExpression = ExpressionHelper.CreateOrGetParameterExpression(sourceType, sourceType.Name, Factory.Store);

            Expression body = MakeConditionExpression(condition, parameterExpression, ref sourceExpression);

            if (body != null)
            {
                sourceExpression = MakeWhere(sourceType, sourceExpression, body, parameterExpression);
            }

            return sourceExpression;
        }