示例#1
0
        protected virtual void VisitNew(NewExpression nex, SqlVistorFlag flag)
        {
            for (var i = 0; i < nex.Members.Count; i++)
            {
                var arg    = nex.Arguments[i];
                var member = nex.Members[i];

                flag.Append(flag.GetColName(member.Name)).Append("=");
                VisitRight(arg, flag);
            }
        }
示例#2
0
        protected virtual void VisitMember(MemberExpression exp, SqlVistorFlag flag)
        {
            if (exp.Expression != null &&
                exp.Expression.NodeType == ExpressionType.Parameter)
            {
                if (flag.is_right && flag.vistor_type == SqlVistorType.Update)
                {
                    var proParaName = flag.GetParaName(exp.Member.Name);
                    flag.Append(proParaName, true);

                    AddMemberProperty(proParaName, exp.Member.Name);
                }
                else
                {
                    if (exp.Member.DeclaringType.GetTypeInfo().IsGenericType &&
                        exp.Member.DeclaringType?.GetGenericTypeDefinition() == typeof(Nullable <>))
                    {
                        if (exp.Member.Name == "Value")
                        {
                            Visit(exp.Expression, flag);
                        }

                        if (exp.Member.Name != "HasValue")
                        {
                            return;
                        }

                        var doesNotEqualNull = Expression.MakeBinary(ExpressionType.NotEqual, exp.Expression,
                                                                     Expression.Constant(null));
                        Visit(doesNotEqualNull, flag);
                    }
                    else
                    {
                        flag.Append(flag.GetColName(exp.Member.Name), true);
                    }
                }
            }
            else
            {
                var value = Expression.Lambda(exp).Compile().DynamicInvoke();
                Visit(Expression.Constant(value), flag);
            }
        }