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(""); } var argExp = exp.Arguments[1]; var result = "AND " + 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); }
public string GetValue(Expression expression) { var exp = expression as MethodCallExpression; var argExp = exp.Arguments[0]; var result = "AND " + SubTools.GetMethodValue(this.Context, argExp, ResolveExpressType.WhereMultiple); var regex = @"^AND (\@Const\d+) $"; if (this.Context is OracleExpressionContext) { regex = @"^AND (\:Const\d+) $"; } if (this.Context is DmExpressionContext) { regex = @"^AND (\:Const\d+) $"; } if (Regex.IsMatch(result, regex)) { result = "AND " + this.Context.Parameters.First(it => it.ParameterName == Regex.Match(result, regex).Groups[1].Value).Value; return(result); } var selfParameterName = this.Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot; if (this.Context.JoinIndex == 0) { result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context)); } return(result); }
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 argLambda = argExp as LambdaExpression; if (this.Context.InitMappingInfo != null && argLambda != null && argLambda.Parameters.Count > 0) { foreach (var item in argLambda.Parameters) { this.Context.InitMappingInfo(item.Type); } this.Context.RefreshMapping(); } var result = "MIN(" + 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); }
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 selfParameterName = Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot; result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context)); return(result); }
public string GetValue(Expression expression) { var exp = expression as MethodCallExpression; if (Regex.Matches(expression.ToString(), "Subqueryable").Count >= 2) { new SubSelect() { Context = this.Context }.SetShortName(exp, "+"); } 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 (this.Context is DmExpressionContext) { regex = @"^WHERE (\:Const\d+) $"; } if (Regex.IsMatch(result, regex)) { var value = GetValue(result, regex); if (value is Expression) { var p = this.Context.Parameters.First(it => it.ParameterName == Regex.Match(result, regex).Groups[1].Value); result = "WHERE " + SubTools.GetMethodValue(Context, value as Expression, ResolveExpressType.WhereMultiple); argExp = value as Expression; this.Context.Parameters.Remove(p); } else { result = "WHERE " + value; return(result); } } var selfParameterName = Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot; if (this.Context.JoinIndex == 0) { result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context)); } return(result); }
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); }
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 = "SUM(" + 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); }
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); }
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()); } if (Regex.Matches(expression.ToString(), "Subqueryable").Count >= 2) { new SubSelect() { Context = this.Context }.SetShortNameNext(exp, "+"); } 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; if (this.Context.JoinIndex == 0) { result = result.Replace(selfParameterName, SubTools.GetSubReplace(this.Context)); } return(result); }