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); }
Criterion ProcessCriteria(Expression expression) { if (expression is BinaryExpression binary) { if (binary.NodeType == ExpressionType.OrElse) { return(BinaryCriterion.From <T>(binary)); } } return(CreateCriterion(expression)); }
public static Criterion From(BinaryExpression expression) { if (expression.NodeType == ExpressionType.OrElse || expression.NodeType == ExpressionType.AndAlso) { return(BinaryCriterion.From(expression)); } Criterion create(string property, Expression value, bool flipped = false) { if (property.IsEmpty()) { return(null); } return(new Criterion( property, expression.NodeType.ToFilterFunction(flipped), value.GetValue())); } var left = Analyse(expression.Left); var right = Analyse(expression.Right); if (left.WasParameter) { return(create("ID", expression.Right)); } if (right.WasParameter) { return(create("ID", expression.Left, flipped: true)); } if (left.FromParameter && right.FromParameter && left.Member.Expression == right.Member.Expression) { return(new DynamicValueCriterion( left.Member.GetDatabaseColumnPath(), expression.NodeType.ToFilterFunction(), right.Member.GetDatabaseColumnPath())); } if (left.FromParameter) { return(create(left.Member.GetDatabaseColumnPath(), expression.Right)); } if (right.FromParameter) { return(create(right.Member.GetDatabaseColumnPath(), expression.Left, flipped: true)); } return(null); }
public BinaryCriterion And(BinaryCriterion left, BinaryCriterion right) { return(new BinaryCriterion(left, BinaryOperator.AND, right)); }
public BinaryCriterion Or(BinaryCriterion left, BinaryCriterion right) { return(new BinaryCriterion(left, BinaryOperator.OR, right)); }
public BinaryCriterion And(BinaryCriterion left, BinaryCriterion right) => new BinaryCriterion(left, BinaryOperator.AND, right);
public BinaryCriterion Or(BinaryCriterion left, BinaryCriterion right) => new BinaryCriterion(left, BinaryOperator.OR, right);