예제 #1
0
        public static Expression CreateKeyValueAnyExpression(this Expression valueParam, EnumerableMethodName enumerableMethodName, string propertyName, Expression boolExpression, ParameterExpression keyValueParm)
        {
            var enumerableProperty = Expression.Property(valueParam, propertyName);
            var valueLamda         = Expression.Lambda <Func <KeyValuePair <string, IEnumerable <string> >, bool> >(boolExpression, new[] { keyValueParm });

            var nullConst        = Expression.Constant(null);
            var notEqualNullExpr = Expression.NotEqual(enumerableProperty, nullConst);

            return(Expression.AndAlso(notEqualNullExpr, Expression.Call(typeof(Enumerable), enumerableMethodName.ToString(), new[] { typeof(KeyValuePair <string, IEnumerable <string> >) }, enumerableProperty, valueLamda)));
        }
예제 #2
0
        //public static Expression CreateKeyAnyExpression(this Expression valueParam, EnumerableMethodName enumerableMethodName, string propertyName, Expression boolExpression, ParameterExpression keyValueParm)
        //{
        //    var enumerableProperty = Expression.Property(valueParam, "Attributes");
        //    var valueLamda = Expression.Lambda<Func<Dictionary<string, IEnumerable<string>>, bool>>(boolExpression, new[] { keyValueParm });

        //    var nullConst = Expression.Constant(null);
        //    var notEqualNullExpr = Expression.NotEqual(enumerableProperty, nullConst);
        //    return Expression.AndAlso(notEqualNullExpr, Expression.Call(typeof(Enumerable), enumerableMethodName.ToString(), new[] { typeof(KeyValuePair<string, IEnumerable<string>>) }, enumerableProperty, valueLamda));
        //}

        public static Expression CreateElementsWhereExpression <TInput>(this ParameterExpression valueParam, EnumerableMethodName enumerableMethodName, string propertyName, Expression boolExpression)
        {
            var enumerableProperty = Expression.Property(valueParam, propertyName);
            var valueLamda         = Expression.Lambda <Func <TInput, bool> >(boolExpression, new[] { valueParam });

            return(Expression.Call(typeof(Enumerable), enumerableMethodName.ToString(), new[] { typeof(TInput) }, enumerableProperty, valueLamda));
        }
예제 #3
0
        public static Expression CreateKeyValueBoolExpression <TValue>(this Expression keyValueParm, ParameterExpression valueParam, Expression valueExpression, EnumerableMethodName enumerableMethodName)
        {
            var valueType  = typeof(TValue);
            var valueProp  = Expression.Property(keyValueParm, "Value");
            var valueLamda = Expression.Lambda <Func <TValue, bool> >(valueExpression, new[] { valueParam });

            var nullConst        = Expression.Constant(null);
            var notEqualNullExpr = Expression.NotEqual(valueProp, nullConst);

            return(Expression.AndAlso(notEqualNullExpr, Expression.Call(typeof(Enumerable), enumerableMethodName.ToString(), new[] { valueType }, valueProp, valueLamda)));
        }