Ejemplo n.º 1
0
 public override void VisitSelectClause(SelectClause selectClause, QueryModel queryModel)
 {
     Log("VisitSelectClause: " + selectClause, logLevel++);
     _queryParts.SelectPart = SqlExpressionTreeVisitor.GetSqlExpression(selectClause.Selector, ",");
     base.VisitSelectClause(selectClause, queryModel);
     logLevel--;
 }
Ejemplo n.º 2
0
 public override void VisitWhereClause(WhereClause whereClause, QueryModel queryModel, int index)
 {
     Log($"VisitWhereClause({index}): " + whereClause, logLevel++);
     _queryParts.AddWherePart(SqlExpressionTreeVisitor.GetSqlExpression(whereClause.Predicate));
     base.VisitWhereClause(whereClause, queryModel, index);
     logLevel--;
 }
Ejemplo n.º 3
0
        public override void VisitOrderByClause(OrderByClause orderByClause, QueryModel queryModel, int index)
        {
            Log($"VisitOrderByClause({index}): " + orderByClause, logLevel++);

            var orderings = orderByClause.Orderings;

            _queryParts.AddOrderByPart(orderings.Select(item => SqlExpressionTreeVisitor.GetSqlExpression(item.Expression) + " " + item.OrderingDirection));
            base.VisitOrderByClause(orderByClause, queryModel, index);
            logLevel--;
        }
Ejemplo n.º 4
0
        private string GetFilter(JoinClause joinClause, string newItemName = null)
        {
            //TODO
            var filter = $"({SqlExpressionTreeVisitor.GetSqlExpression(joinClause.OuterKeySelector)} = {SqlExpressionTreeVisitor.GetSqlExpression(joinClause.InnerKeySelector)})";

            if (newItemName != null)
            {
                filter = filter.Replace($"\"{joinClause.ItemName}\".", $"\"{newItemName}\".");
            }
            return(filter);
        }
Ejemplo n.º 5
0
        public static string GetSqlExpression(Expression exp, string separator = "")
        {
            var visitor = new SqlExpressionTreeVisitor(separator);

            visitor.Visit(exp);
            var str = visitor.sql.ToString();

            if (separator.Length > 0 && str.Length > 0)
            {
                str = str.Remove(str.Length - separator.Length);
            }
            return(str);
        }