コード例 #1
0
ファイル: SubWhereIF.cs プロジェクト: rockmyid/autumn.boot
        public string GetValue(Expression expression)
        {
            var    exp   = expression as MethodCallExpression;
            object value = null;

            try
            {
                value = ExpressionTool.DynamicInvoke(exp.Arguments[0]);
            }
            catch
            {
                Check.Exception(true, ErrorMessage.WhereIFCheck, exp.Arguments[0].ToString());
            }
            var isWhere = Convert.ToBoolean(value);

            if (!Convert.ToBoolean(isWhere))
            {
                return("WHERE 1=1 ");
            }
            var argExp            = exp.Arguments[1];
            var result            = "WHERE " + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple);;
            var selfParameterName = Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot;

            result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));
            return(result);
        }
コード例 #2
0
        public string GetValue(Expression expression)
        {
            if (this.Context is OracleExpressionContext)
            {
                throw new Exception("Oracle Subquery can't OrderBy");
            }
            var exp               = expression as MethodCallExpression;
            var argExp            = exp.Arguments[0];
            var result            = "ORDER BY " + SubTools.GetMethodValue(this.Context, argExp, ResolveExpressType.FieldSingle);
            var selfParameterName = this.Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot;

            result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));
            return(result);
        }
コード例 #3
0
        public string GetValue(Expression expression = null)
        {
            var exp        = expression as MethodCallExpression;
            var argExp     = exp.Arguments[0];
            var parametres = (argExp as LambdaExpression).Parameters;

            if ((argExp as LambdaExpression).Body is UnaryExpression)
            {
                argExp = ((argExp as LambdaExpression).Body as UnaryExpression).Operand;
            }
            var result            = "MAX(" + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple) + ")";
            var selfParameterName = Context.GetTranslationColumnName(parametres.First().Name) + UtilConstants.Dot;

            result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));
            return(result);
        }
コード例 #4
0
ファイル: SubGroupBy.cs プロジェクト: rockmyid/autumn.boot
        public string GetValue(Expression expression)
        {
            var exp    = expression as MethodCallExpression;
            var argExp = exp.Arguments[0];
            var type   = ResolveExpressType.FieldSingle;

            if ((argExp as LambdaExpression).Body is NewExpression)
            {
                type = ResolveExpressType.ArraySingle;
            }
            var result = "GROUP BY " + SubTools.GetMethodValue(this.Context, argExp, type);

            result = result.TrimEnd(',');
            var selfParameterName = this.Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot;

            result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));
            return(result);
        }
コード例 #5
0
ファイル: SubWhere.cs プロジェクト: rockmyid/autumn.boot
        public string GetValue(Expression expression)
        {
            var exp    = expression as MethodCallExpression;
            var argExp = exp.Arguments[0];
            var result = "WHERE " + SubTools.GetMethodValue(Context, argExp, ResolveExpressType.WhereMultiple);


            var regex = @"^WHERE  (\@Const\d+) $";

            if (this.Context is OracleExpressionContext)
            {
                regex = @"^WHERE  (\:Const\d+) $";
            }
            if (Regex.IsMatch(result, regex))
            {
                result = "WHERE " + this.Context.Parameters.First(it => it.ParameterName == Regex.Match(result, regex).Groups[1].Value).Value;
                return(result);
            }

            var selfParameterName = Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot;

            result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context));
            return(result);
        }