public Expression GetExpression(ICriteriaLeaf leaf) { var type = _typeRegistry.Lookup(leaf); var typedValue = Converter.NullableSafeChangeType(leaf.Value, type.PropertyType); var accessorExpression = type.AccessorExpression; return Expression.Equal(accessorExpression, Expression.Constant(typedValue, type.PropertyType)); }
public Expression GetExpression(ICriteriaLeaf leaf) { var type = _typeRegistry.Lookup(leaf); var compareType = _typeRegistry.Lookup(String.Format("{0}", leaf.Value)); var accessorExpression = type.AccessorExpression; var outputExpression = compareType.AccessorExpression; return Expression.Equal(accessorExpression, outputExpression); }
public Expression GetExpression(ICriteriaLeaf leaf) { ICriteriaLeafExpressionStrategy strategy; if(_criteriaLeafExpressionStrategies.TryGetValue(leaf.Operator, out strategy) == false) { throw new ArgumentException(String.Format("No CriteriaLeafExpressionStrategy for operator type {0}", leaf.Operator)); } var result = strategy.GetExpression(leaf); return result; }
public Expression GetExpression(ICriteriaLeaf leaf) { var type = _typeRegistry.Lookup(leaf); var itemType = type.PropertyType; if((itemType != typeof(bool)) && (itemType != typeof(bool?))) { throw new ArgumentException(String.Format("Cannot use the IsTrue operator with type '{0}'.", itemType)); } return type.AccessorExpression; }
public Expression GetExpression(ICriteriaLeaf leaf) { var type = _typeRegistry.Lookup(leaf); if(type.PropertyType != typeof(string)) { throw new ArgumentException(String.Format("Operator {0} is not defined for non-string properties.", leaf.Operator)); } var accessorExpression = type.AccessorExpression; var x = Convert.ChangeType(leaf.Value, type.PropertyType); return Expression.Not(Expression.Call(accessorExpression, "EndsWith", new Type[0], new Expression[] { Expression.Constant(x, type.PropertyType) })); }
public Expression GetExpression(ICriteriaLeaf leaf) { Expression result; var type = _typeRegistry.Lookup(leaf); var accessorExpression = type.AccessorExpression; var doesNotEqualNullExpression = Expression.NotEqual(accessorExpression, Expression.Constant(null)); if (typeof(string).IsAssignableFrom(type.PropertyType)) { var doesNotEqualEmptyStringExpression = Expression.NotEqual(accessorExpression, Expression.Constant(String.Empty, type.PropertyType)); result = Expression.AndAlso(doesNotEqualNullExpression, doesNotEqualEmptyStringExpression); } else { result = doesNotEqualNullExpression; } return result; }
private Expression BuildLeafExpression(ICriteriaLeaf leaf) { var result = _leafExpressionStrategy.GetExpression(leaf); return result; }