public void GetExpressionMapping_GetFromParentContext()
        {
            var querySourceReferenceExpression = new QuerySourceReferenceExpression(_parentSource);
            var sqlTableReferenceExpression    = new SqlTableReferenceExpression(_parentSqlTable);

            _parentContext.AddExpressionMapping(querySourceReferenceExpression, sqlTableReferenceExpression);
            Assert.That(_contextWithParent.GetExpressionMapping(querySourceReferenceExpression), Is.SameAs(sqlTableReferenceExpression));
        }
        public void VisitMemberExpression_InnerExpressionIsPrepared()
        {
            var fakeQuerySource = MockRepository.GenerateStub <IQuerySource>();

            fakeQuerySource.Stub(stub => stub.ItemType).Return(typeof(Cook));

            var replacement = Expression.Constant(null, typeof(Cook));

            _context.AddExpressionMapping(new QuerySourceReferenceExpression(fakeQuerySource), replacement);

            var memberExpression = Expression.MakeMemberAccess(
                new QuerySourceReferenceExpression(fakeQuerySource), typeof(Cook).GetProperty("IllnessDays"));
            var result = SqlPreparationFromExpressionVisitor.AnalyzeFromExpression(
                memberExpression,
                _stageMock,
                _generator,
                _methodCallTransformerProvider,
                _context,
                _tableGenerator,
                _someOrderingExtractionPolicy);

            var sqlTable    = result.SqlTable;
            var joinedTable = (SqlJoinedTable)sqlTable.TableInfo;

            Assert.That(((UnresolvedCollectionJoinInfo)joinedTable.JoinInfo).SourceExpression, Is.SameAs(replacement));
        }
Beispiel #3
0
        public void SetUp()
        {
            _stageMock          = MockRepository.GenerateMock <ISqlPreparationStage>();
            _context            = SqlStatementModelObjectMother.CreateSqlPreparationContext();
            _cookMainFromClause = ExpressionHelper.CreateMainFromClause <Cook>();
            _cookQuerySourceReferenceExpression = new QuerySourceReferenceExpression(_cookMainFromClause);
            var source = new UnresolvedTableInfo(_cookMainFromClause.ItemType);

            _sqlTable = new SqlTable(source, JoinSemantics.Inner);
            _context.AddExpressionMapping(new QuerySourceReferenceExpression(_cookMainFromClause), new SqlTableReferenceExpression(_sqlTable));
            _methodCallTransformerProvider = CompoundMethodCallTransformerProvider.CreateDefault();
        }
        public SqlTableBase AddQuerySource(IQuerySource source, Expression fromExpression)
        {
            ArgumentUtility.CheckNotNull("source", source);
            ArgumentUtility.CheckNotNull("fromExpression", fromExpression);

            var fromExpressionInfo = _stage.PrepareFromExpression(fromExpression, _context, info => new SqlTable(info, JoinSemantics.Inner));

            AddPreparedFromExpression(fromExpressionInfo);

            _context.AddExpressionMapping(new QuerySourceReferenceExpression(source), fromExpressionInfo.ItemSelector);
            return(fromExpressionInfo.SqlTable);
        }
    public void SetUp ()
    {
      _context = SqlStatementModelObjectMother.CreateSqlPreparationContext();

      var querySource = ExpressionHelper.CreateMainFromClause<Cook>();
      _sqlTable = new SqlTable (new UnresolvedTableInfo (typeof (Cook)), JoinSemantics.Inner);

      _context.AddExpressionMapping (new QuerySourceReferenceExpression(querySource), new SqlTableReferenceExpression(_sqlTable));

      _querySourceReferenceExpression = new QuerySourceReferenceExpression (querySource);

      _stage = new DefaultSqlPreparationStage (
          CompoundMethodCallTransformerProvider.CreateDefault(), ResultOperatorHandlerRegistry.CreateDefault(), new UniqueIdentifierGenerator());
    }
        public void SetUp()
        {
            _context = SqlStatementModelObjectMother.CreateSqlPreparationContext();

            var querySource = ExpressionHelper.CreateMainFromClause <Cook>();

            _sqlTable = new SqlTable(new UnresolvedTableInfo(typeof(Cook)), JoinSemantics.Inner);

            _context.AddExpressionMapping(new QuerySourceReferenceExpression(querySource), new SqlTableReferenceExpression(_sqlTable));

            _querySourceReferenceExpression = new QuerySourceReferenceExpression(querySource);

            _stage = new DefaultSqlPreparationStage(
                CompoundMethodCallTransformerProvider.CreateDefault(), ResultOperatorHandlerRegistry.CreateDefault(), new UniqueIdentifierGenerator());
        }
Beispiel #7
0
        protected void AddMappingForItemExpression(ISqlPreparationContext context, IStreamedDataInfo dataInfo, Expression replacement)
        {
            Assertion.DebugAssert(dataInfo is StreamedSequenceInfo);

            // Later ResultOperatorHandlers might have expressions that access the value streaming out from this result operator. These expressions must
            // be updated to get their input expression (the ItemExpression of sqlStatement.DataInfo) from the sub-statement table we just created.
            // Therefore, register an expression mapping from the ItemExpression to the new SqlTable.
            // (We cannot use the sqlStatement.SelectExpression for the mapping because that expression has already been transformed and therefore will
            // not compare equal to the expressions of the later result operators as long as we can only compare expressions by reference. The
            // ItemExpression, on the other hand, should compare fine because it is inserted by reference into the result operators' expressions during
            // the front-end's lambda resolution process.)

            var itemExpressionNowInSqlTable = ((StreamedSequenceInfo)dataInfo).ItemExpression;

            context.AddExpressionMapping(itemExpressionNowInSqlTable, replacement);
        }
 public void AddExpressionMapping()
 {
     _context.AddExpressionMapping(new QuerySourceReferenceExpression(_source), new SqlTableReferenceExpression(_sqlTable));
     Assert.That(_context.GetExpressionMapping(new QuerySourceReferenceExpression(_source)), Is.Not.Null);
 }