Exemple #1
0
        private static Expression GetExpression <T>(ParameterExpression param, NWFilter filter) where T : IBusEntity, new()
        {
            MemberExpression   member   = Expression.Property(param, filter.PropertyName);
            ConstantExpression constant = Expression.Constant(filter.Value);

            switch (filter.Operation)
            {
            case G__ExpressionType.Equal:
                return(Expression.Equal(member, constant));

            case G__ExpressionType.GreaterThan:
                return(Expression.GreaterThan(member, constant));

            case G__ExpressionType.GreaterThanOrEqual:
                return(Expression.GreaterThanOrEqual(member, constant));

            case G__ExpressionType.LessThan:
                return(Expression.LessThan(member, constant));

            case G__ExpressionType.LessThanOrEqual:
                return(Expression.LessThanOrEqual(member, constant));

            case G__ExpressionType.Contains:
                return(Expression.Call(member, containsMethod, constant));

            case G__ExpressionType.StartsWith:
                return(Expression.Call(member, startsWithMethod, constant));

            case G__ExpressionType.EndsWith:
                return(Expression.Call(member, endsWithMethod, constant));
            }

            return(null);
        }
Exemple #2
0
        private static BinaryExpression GetExpression <T>(ParameterExpression param, NWFilter filter1, NWFilter filter2) where T : IBusEntity, new()
        {
            Expression bin1 = GetExpression <T>(param, filter1);
            Expression bin2 = GetExpression <T>(param, filter2);

            return(Expression.AndAlso(bin1, bin2));
        }