protected override Expression VisitUnary(UnaryExpression node)
        {
            switch (node.NodeType)
            {
            case ExpressionType.Convert:
            case ExpressionType.ConvertChecked:

                var me = node.Operand as MemberExpression;
                var parameterExpression = node.GetParameterExpression();
                var sType = parameterExpression?.Type;
                if (me != null && (sType != null && me.Expression.NodeType == ExpressionType.MemberAccess && me.Type.IsLiteralType()))
                {
                    //just pass me and let the FindMemberExpressionsVisitor handle removing of the value type
                    //me.Expression will not match the PathMap name.
                    return(Visit(me));
                }
                else
                {
                    return(base.VisitUnary(node));
                }

            default:
                return(base.VisitUnary(node));
            }
        }
Exemple #2
0
        protected override Expression VisitUnary(UnaryExpression node)
        {
            switch (node.NodeType)
            {
            case ExpressionType.Convert:
            case ExpressionType.ConvertChecked:

                var me = node.Operand as MemberExpression;
                var parameterExpression = node.GetParameterExpression();
                var sType = parameterExpression?.Type;
                if (me != null && (sType != null && me.Expression.NodeType == ExpressionType.MemberAccess && (me.Type == typeof(string) || me.Type.GetTypeInfo().IsValueType || (me.Type.GetTypeInfo().IsGenericType &&
                                                                                                                                                                                 me.Type.GetGenericTypeDefinition() == typeof(Nullable <>) &&
                                                                                                                                                                                 Nullable.GetUnderlyingType(me.Type).GetTypeInfo().IsValueType))))
                {
                    //ParameterExpression parameter = me.Expression.GetParameter();
                    //string fullName = me.Expression.GetPropertyFullName();
                    //return parameter.BuildExpression(sType, fullName);
                    return(Visit(me.Expression));
                }
                else
                {
                    return(base.VisitUnary(node));
                }

            default:
                return(base.VisitUnary(node));
            }
        }