public static TreeExpression Compile <T>(SQLInfo <T> sql, Expression Expr) { var ret = new TreeExpression(); if (Expr is BinaryExpression) { ret.Op = Utils.GetOp(Expr.NodeType); ret.Left = Compile(sql, ((BinaryExpression)Expr).Left); ret.Right = Compile(sql, ((BinaryExpression)Expr).Right); return(ret); } if (Expr is MemberExpression) { return(ComplieWithMemberExpression(sql, (MemberExpression)Expr)); } if (Expr is ConstantExpression) { return(CompileWitConstantEpxression(sql, (ConstantExpression)Expr)); } if (Expr is UnaryExpression) { return(Compile(sql, ((UnaryExpression)Expr).Operand)); } throw new NotImplementedException(); }
private static string GetTextField <T>(SQLInfo <T> sql, TreeExpression expr, string quote) { if (expr.Op != null) { return("(" + GetTextField(sql, expr.Left, quote) + ")" + expr.Op + "(" + GetTextField(sql, expr.Right, quote) + ")"); } if (expr.Field != null) { return(GetTextField(sql, expr.Field, quote)); } if (expr.Value != null) { if (sql.Params == null) { sql.Params = new List <FieldValue>(); } sql.Params.Add(expr.Value); return("{" + (sql.Params.Count - 1) + "}"); } throw new NotImplementedException(); }
//[System.Diagnostics.DebuggerStepThrough] private static TreeExpression GetExpression <T>( SQLInfo <T> sql, List <DataFieldInfo> fields1, List <DataFieldInfo> fields2, ParameterExpression pExpr1, ParameterExpression pExpr2, string alias1, string alias2, Expression Expr) { var ret = new TreeExpression(); if (Expr is UnaryExpression) { return(GetExpression(sql, fields1, fields2, pExpr1, pExpr2, alias1, alias2, ((UnaryExpression)Expr).Operand)); } if (Expr is MemberExpression) { return(GetExpressionInMemberExpression(sql, fields1, fields2, pExpr1, pExpr2, alias1, alias2, (MemberExpression)Expr)); } return(ret); }