private static string Write(TextWriter writer, Expression expression, SqlType bizSql) { expression = PartialEvaluator.Eval(expression); ExpressionWriterSql bizR = new ExpressionWriterSql(writer) { _bizRead = bizSql }; bizR.Visit(expression); string result; switch (bizSql) { case SqlType.Order: result = Regex.Replace(bizR._aiOrdeRsult, @",\s?$", ""); return(result); case SqlType.Where: result = Regex.Replace(bizR._aiWhereResult, @"And\s?$", ""); return(result);; default: return(string.Empty); } }
private void SetOrderBy(Expression aiExp) { var itemstr = ExpressionWriterSql.BizWhereWriteToString(aiExp, SqlType.Order); if (string.IsNullOrWhiteSpace(_aiOrderByStr)) { _aiOrderByStr = itemstr; } else { _aiOrderByStr = _aiOrderByStr + "," + itemstr; } }
private void SetWhere(Expression aiExp, LambdaExpUnion bizUion = LambdaExpUnion.And) { var itemstr = ExpressionWriterSql.BizWhereWriteToString(aiExp, SqlType.Where); if (string.IsNullOrWhiteSpace(_aiWhereStr)) { _aiWhereStr = itemstr; } else { if (bizUion == LambdaExpUnion.Or) { _aiWhereStr = _aiWhereStr + " Or " + itemstr; } else { _aiWhereStr = _aiWhereStr + " And " + itemstr; } } }