Exemplo n.º 1
0
        protected virtual void ExpressionParse(UnaryExpression expression)
        {
            if (!(expression.Operand is MemberExpression))
            {
                ExpressionParse(expression.Operand);
                return;
            }
            var member = new MemberInfoEx(((MemberExpression)expression.Operand).Member);

            switch (expression.NodeType)
            {
            case ExpressionType.Not:
                Params.Add(ConstSet.True);
                sb.Append(CloumnName(member.Name) + " " + ConstSet.Eq + " " + ConstSet.ParamChar);
                break;

            case ExpressionType.NotEqual:
                Params.Add(ConstSet.False);
                sb.Append(CloumnName(member.Name) + " " + ConstSet.Eq + " " + ConstSet.ParamChar);
                break;

            case ExpressionType.Convert:
                Params.Add(member.GetValue(null));
                sb.Append(ConstSet.ParamChar);
                break;

            default:
                sb.Append(CloumnName(member.Name));
                break;
            }
        }
Exemplo n.º 2
0
        protected object GetMemberExpressionValue(MemberExpression expression)
        {
            var member = new MemberInfoEx(expression.Member);
            var exp    = expression.Expression;

            if (exp is ConstantExpression)
            {
                return(member.GetValue(((ConstantExpression)exp).Value));
            }
            else if (exp == null)
            {
                return(member.GetValue(null));
            }
            else if (exp is MemberExpression)
            {
                return(member.GetValue(GetMemberExpressionValue((MemberExpression)exp)));
            }
            return(null);
        }
Exemplo n.º 3
0
        protected virtual void ExpressionParse(MemberExpression expression)
        {
            var member = new MemberInfoEx(expression.Member);

            if (expression.Expression is ParameterExpression)
            {
                if (member.MemberType == typeof(bool) && !isOpt)
                {
                    Params.Add(ConstSet.True);
                    sb.Append(CloumnName(member.Name) + " " + ConstSet.Eq + " " + ConstSet.ParamChar);
                }
                else
                {
                    sb.Append(CloumnName(member.Name));
                }
            }
            else
            {
                var val = GetMemberExpressionValue((MemberExpression)expression);
                if (val is bool)
                {
                    sb.Append(BoolParse((bool)val));
                }
                else
                {
                    if (val != null)
                    {
                        Params.Add(val);
                        sb.Append(ConstSet.ParamChar);
                    }
                    else
                    {
                        sb.Append(ConstSet.NullChar);
                    }
                }
            }
        }