示例#1
0
 public void Visit(SqlExpression sqlExpression)
 {
     if (visitedExpressions.Contains(sqlExpression))
     {
         return;
     }
     visitedExpressions.Add(sqlExpression);
     sqlExpression.AcceptVisitor(this);
 }
示例#2
0
        private void AddComputedExpression(AddValueContext addContext)
        {
            SqlTableColumn       column           = SqlDml.TableColumn(addContext.Statement.Table, addContext.Field.Column.Name);
            var                  all              = Expression.Call(Expression.Constant(parent.Session.Query), "All", new[] { typeof(T) });
            MethodCallExpression selectExpression = Expression.Call(
                typeof(Queryable),
                "OrderBy",
                addContext.Lambda.Type.GetGenericArguments(),
                all,
                addContext.Lambda);
            QueryTranslationResult request = parent.GetRequest(parent.QueryProvider.CreateQuery <T>(selectExpression));
            var           sqlSelect        = ((SqlSelect)request.Query);
            SqlExpression ex = sqlSelect.OrderBy[0].Expression;

            parent.Bindings.AddRange(request.ParameterBindings);

            if (parent.JoinedTableRef != null)
            {
                ex.AcceptVisitor(new ComputedExpressionSqlVisitor(sqlSelect.From, parent.JoinedTableRef));
            }

            addContext.Statement.AddValue(column, ex);
        }