Beispiel #1
0
        public virtual Expression ApplyContext(Expression expression, SqlExpressionContext expressionContext, IMappingResolutionContext mappingResolutionContext)
        {
            ArgumentUtility.CheckNotNull("expression", expression);
            ArgumentUtility.CheckNotNull("mappingResolutionContext", mappingResolutionContext);

            return(SqlContextExpressionVisitor.ApplySqlExpressionContext(expression, expressionContext, this, mappingResolutionContext));
        }
Beispiel #2
0
        public virtual SqlStatement ApplySelectionContext(SqlStatement sqlStatement, SqlExpressionContext expressionContext, IMappingResolutionContext mappingResolutionContext)
        {
            ArgumentUtility.CheckNotNull("sqlStatement", sqlStatement);
            ArgumentUtility.CheckNotNull("mappingResolutionContext", mappingResolutionContext);

            return(SqlContextSelectionAdjuster.ApplyContext(sqlStatement, expressionContext, this, mappingResolutionContext));
        }
Beispiel #3
0
        public virtual ITableInfo ApplyContext(ITableInfo tableInfo, SqlExpressionContext expressionContext, IMappingResolutionContext mappingResolutionContext)
        {
            ArgumentUtility.CheckNotNull("tableInfo", tableInfo);
            ArgumentUtility.CheckNotNull("mappingResolutionContext", mappingResolutionContext);

            return(SqlContextTableInfoVisitor.ApplyContext(tableInfo, expressionContext, this, mappingResolutionContext));
        }
Beispiel #4
0
        public virtual IJoinInfo ApplyContext(IJoinInfo joinInfo, SqlExpressionContext expressionContext, IMappingResolutionContext mappingResolutionContext)
        {
            ArgumentUtility.CheckNotNull("joinInfo", joinInfo);
            ArgumentUtility.CheckNotNull("mappingResolutionContext", mappingResolutionContext);

            return(SqlContextJoinInfoVisitor.ApplyContext(joinInfo, expressionContext, this, mappingResolutionContext));
        }
    public static IJoinInfo ApplyContext (IJoinInfo joinInfo, SqlExpressionContext expressionContext, IMappingResolutionStage stage, IMappingResolutionContext mappingResolutionContext)
    {
      ArgumentUtility.CheckNotNull ("joinInfo", joinInfo);
      ArgumentUtility.CheckNotNull ("stage", stage);

      var visitor = new SqlContextJoinInfoVisitor (stage, expressionContext, mappingResolutionContext);
      return joinInfo.Accept (visitor);
    }
    protected SqlContextTableInfoVisitor (IMappingResolutionStage stage, SqlExpressionContext expressionContext, IMappingResolutionContext mappingResolutionContext)
    {
      ArgumentUtility.CheckNotNull ("stage", stage);
      ArgumentUtility.CheckNotNull ("mappingResolutionContext", mappingResolutionContext);

      _stage = stage;
      _expressionContext = expressionContext;
      _mappingResolutionContext = mappingResolutionContext;
    }
        public static IJoinInfo ApplyContext(IJoinInfo joinInfo, SqlExpressionContext expressionContext, IMappingResolutionStage stage, IMappingResolutionContext mappingResolutionContext)
        {
            ArgumentUtility.CheckNotNull("joinInfo", joinInfo);
            ArgumentUtility.CheckNotNull("stage", stage);

            var visitor = new SqlContextJoinInfoVisitor(stage, expressionContext, mappingResolutionContext);

            return(joinInfo.Accept(visitor));
        }
    protected SqlContextExpressionVisitor (SqlExpressionContext currentContext, IMappingResolutionStage stage, IMappingResolutionContext context)
    {
      ArgumentUtility.CheckNotNull ("stage", stage);
      ArgumentUtility.CheckNotNull ("context", context);

      _currentContext = currentContext;
      _stage = stage;
      _context = context;
    }
Beispiel #9
0
        protected SqlContextTableInfoVisitor(IMappingResolutionStage stage, SqlExpressionContext expressionContext, IMappingResolutionContext mappingResolutionContext)
        {
            ArgumentUtility.CheckNotNull("stage", stage);
            ArgumentUtility.CheckNotNull("mappingResolutionContext", mappingResolutionContext);

            _stage                    = stage;
            _expressionContext        = expressionContext;
            _mappingResolutionContext = mappingResolutionContext;
        }
        protected SqlContextExpressionVisitor(SqlExpressionContext currentContext, IMappingResolutionStage stage, IMappingResolutionContext context)
        {
            ArgumentUtility.CheckNotNull("stage", stage);
            ArgumentUtility.CheckNotNull("context", context);

            _currentContext = currentContext;
            _stage          = stage;
            _context        = context;
        }
    public static SqlStatement ApplyContext (SqlStatement sqlStatement, SqlExpressionContext expressionContext, IMappingResolutionStage stage, IMappingResolutionContext mappingresolutionContext)
    {
      ArgumentUtility.CheckNotNull ("sqlStatement", sqlStatement);
      ArgumentUtility.CheckNotNull ("stage", stage);
      ArgumentUtility.CheckNotNull ("mappingresolutionContext", mappingresolutionContext);

      var visitor = new SqlContextSelectionAdjuster (stage, mappingresolutionContext);
      return visitor.VisitSqlStatement (sqlStatement, expressionContext);
    }
    public static Expression ApplySqlExpressionContext (
        Expression expression, SqlExpressionContext initialSemantics, IMappingResolutionStage stage, IMappingResolutionContext context)
    {
      ArgumentUtility.CheckNotNull ("expression", expression);
      ArgumentUtility.CheckNotNull ("stage", stage);
      ArgumentUtility.CheckNotNull ("context", context);

      var visitor = new SqlContextExpressionVisitor (initialSemantics, stage, context);
      return visitor.VisitExpression (expression);
    }
Beispiel #13
0
        public static SqlStatement ApplyContext(SqlStatement sqlStatement, SqlExpressionContext expressionContext, IMappingResolutionStage stage, IMappingResolutionContext mappingresolutionContext)
        {
            ArgumentUtility.CheckNotNull("sqlStatement", sqlStatement);
            ArgumentUtility.CheckNotNull("stage", stage);
            ArgumentUtility.CheckNotNull("mappingresolutionContext", mappingresolutionContext);

            var visitor = new SqlContextSelectionAdjuster(stage, mappingresolutionContext);

            return(visitor.VisitSqlStatement(sqlStatement, expressionContext));
        }
Beispiel #14
0
 public SqlExpression(IDatabase database)
 {
     modelDef                         = PocoData.ForType(typeof(T), database.PocoDataFactory);
     _database                        = database;
     _databaseType                    = database.DatabaseType;
     PrefixFieldWithTableName         = false;
     WhereStatementWithoutWhereString = false;
     paramPrefix                      = "@";
     members = new List <string>();
     Context = new SqlExpressionContext(this);
 }
        public static Expression ApplySqlExpressionContext(
            Expression expression, SqlExpressionContext initialSemantics, IMappingResolutionStage stage, IMappingResolutionContext context)
        {
            ArgumentUtility.CheckNotNull("expression", expression);
            ArgumentUtility.CheckNotNull("stage", stage);
            ArgumentUtility.CheckNotNull("context", context);

            var visitor = new SqlContextExpressionVisitor(initialSemantics, stage, context);

            return(visitor.Visit(expression));
        }
    public SqlStatement VisitSqlStatement (SqlStatement sqlStatement, SqlExpressionContext expressionContext)
    {
      ArgumentUtility.CheckNotNull ("sqlStatement", sqlStatement);

      if (expressionContext == SqlExpressionContext.PredicateRequired)
        throw new InvalidOperationException ("A SqlStatement cannot be used as a predicate.");

      var statementBuilder = new SqlStatementBuilder (sqlStatement);

      var newSelectProjection = _stage.ApplyContext (sqlStatement.SelectProjection, expressionContext, _mappingResolutionContext);
      statementBuilder.SelectProjection = newSelectProjection;
      statementBuilder.RecalculateDataInfo (sqlStatement.SelectProjection);

      var newSqlStatement = statementBuilder.GetSqlStatement();
      return newSqlStatement.Equals (sqlStatement) ? sqlStatement : newSqlStatement;
    }
Beispiel #17
0
        public SqlStatement VisitSqlStatement(SqlStatement sqlStatement, SqlExpressionContext expressionContext)
        {
            ArgumentUtility.CheckNotNull("sqlStatement", sqlStatement);

            if (expressionContext == SqlExpressionContext.PredicateRequired)
            {
                throw new InvalidOperationException("A SqlStatement cannot be used as a predicate.");
            }

            var statementBuilder = new SqlStatementBuilder(sqlStatement);

            var newSelectProjection = _stage.ApplyContext(sqlStatement.SelectProjection, expressionContext, _mappingResolutionContext);

            statementBuilder.SelectProjection = newSelectProjection;
            statementBuilder.RecalculateDataInfo(sqlStatement.SelectProjection);

            var newSqlStatement = statementBuilder.GetSqlStatement();

            return(newSqlStatement.Equals(sqlStatement) ? sqlStatement : newSqlStatement);
        }
 private Expression ApplySqlExpressionContext(Expression expression, SqlExpressionContext expressionContext)
 {
     return(ApplySqlExpressionContext(expression, expressionContext, _stage, _context));
 }
        private Expression VisitChildrenWithGivenSemantics(Expression expression, SqlExpressionContext childContext)
        {
            var visitor = new SqlContextExpressionVisitor(childContext, _stage, _context);

            return(visitor.VisitExtension(expression));
        }
 public TestableSqlContextExpressionVisitor (SqlExpressionContext currentContext, IMappingResolutionStage stage, IMappingResolutionContext context)
     : base (currentContext, stage, context)
 {
 }
    public virtual IJoinInfo ApplyContext (IJoinInfo joinInfo, SqlExpressionContext expressionContext, IMappingResolutionContext mappingResolutionContext)
    {
      ArgumentUtility.CheckNotNull ("joinInfo", joinInfo);
      ArgumentUtility.CheckNotNull ("mappingResolutionContext", mappingResolutionContext);

      return SqlContextJoinInfoVisitor.ApplyContext (joinInfo, expressionContext, this, mappingResolutionContext);
    }
 private Expression VisitChildrenWithGivenSemantics (ExtensionExpression expression, SqlExpressionContext childContext)
 {
   var visitor = new SqlContextExpressionVisitor (childContext, _stage, _context);
   return visitor.VisitExtensionExpression (expression);
 }
    public virtual ITableInfo ApplyContext (ITableInfo tableInfo, SqlExpressionContext expressionContext, IMappingResolutionContext mappingResolutionContext)
    {
      ArgumentUtility.CheckNotNull ("tableInfo", tableInfo);
      ArgumentUtility.CheckNotNull ("mappingResolutionContext", mappingResolutionContext);

      return SqlContextTableInfoVisitor.ApplyContext (tableInfo, expressionContext, this, mappingResolutionContext);
    }
    public virtual Expression ApplyContext (Expression expression, SqlExpressionContext expressionContext, IMappingResolutionContext mappingResolutionContext)
    {
      ArgumentUtility.CheckNotNull ("expression", expression);
      ArgumentUtility.CheckNotNull ("mappingResolutionContext", mappingResolutionContext);

      return SqlContextExpressionVisitor.ApplySqlExpressionContext (expression, expressionContext, this, mappingResolutionContext);
    }
    public virtual SqlStatement ApplySelectionContext (SqlStatement sqlStatement, SqlExpressionContext expressionContext, IMappingResolutionContext mappingResolutionContext)
    {
      ArgumentUtility.CheckNotNull ("sqlStatement", sqlStatement);
      ArgumentUtility.CheckNotNull ("mappingResolutionContext", mappingResolutionContext);

      return SqlContextSelectionAdjuster.ApplyContext (sqlStatement, expressionContext, this, mappingResolutionContext);
    }
Beispiel #26
0
 public TestableSqlContextExpressionVisitor(SqlExpressionContext currentContext, IMappingResolutionStage stage, IMappingResolutionContext context)
     : base(currentContext, stage, context)
 {
 }
 private Expression ApplySqlExpressionContext (Expression expression, SqlExpressionContext expressionContext)
 {
   return ApplySqlExpressionContext (expression, expressionContext, _stage, _context);
 }