public static Criterion From(BinaryExpression expression)
        {
            if (expression.NodeType == ExpressionType.OrElse || expression.NodeType == ExpressionType.AndAlso)
            {
                return(BinaryCriterion.From(expression));
            }

            Criterion create(string property)
            {
                if (property.IsEmpty())
                {
                    return(null);
                }
                return(new Criterion(property, expression.NodeType.ToFilterFunction(), expression.Right.GetValue()));
            }

            var left = expression.Left;

            if (left is ParameterExpression)
            {
                return(create("ID"));
            }

            if (left is MemberExpression memberEx)
            {
                return(create(memberEx.GetDatabaseColumnPath()));
            }

            if (left is UnaryExpression unary && unary.Operand is MemberExpression member)
            {
                return(create(member.GetDatabaseColumnPath()));
            }

            return(null);
        }
Beispiel #2
0
        Criterion ProcessCriteria(Expression expression)
        {
            var binary = expression as BinaryExpression;

            if (binary != null)
            {
                if (binary.NodeType == ExpressionType.OrElse)
                {
                    var criterion = BinaryCriterion.From <T>(binary);

                    if (criterion?.IsConvertedCompletely == false)
                    {
                        ConvertedCompletely = false;
                    }

                    return(criterion);
                }
            }
            return(CreateCriterion(expression));
        }