Esempio n. 1
0
        protected override Expression VisitMember(MemberExpression node)
        {
            if (node.Expression is MemberExpression || node.Expression == null)
            {
                var member = Expression.Convert(node, typeof(object));
                var lambda = Expression.Lambda <Func <object> >(member);
                var getter = lambda.Compile();
                var value  = getter();

                Append(ODataConverter.Format(value.GetType(), value));
                return(node);
            }

            var constant = node.Expression as ConstantExpression;

            if (constant != null)
            {
                var field = node.Member as FieldInfo;
                var value = field.GetValue(constant.Value);

                value = ODataConverter.Format(value.GetType(), value);

                Append(value.ToString());
                return(node);
            }

            Append(node.Member.Name);

            return(base.VisitMember(node));
        }
Esempio n. 2
0
        protected override Expression VisitConstant(ConstantExpression node)
        {
            if (node.Value != null && node.Value is IsODataClientContext)
            {
                return(base.VisitConstant(node));
            }

            if (node.Value == null)
            {
                Append("null");
            }
            else
            {
                Append(ODataConverter.Format(node.Value.GetType(), node.Value));
            }

            return(base.VisitConstant(node));
        }