public void Build_WithGroupByExpression() { var sqlGroupExpression = SqlStatementModelObjectMother.CreateSqlGroupingSelectExpression(); sqlGroupExpression.AddAggregationExpressionWithName(Expression.Constant("aggregation1")); sqlGroupExpression.AddAggregationExpressionWithName(Expression.Constant("aggregation2")); var sqlStatement = new SqlStatement( new TestStreamedValueInfo(typeof(int)), _entityExpression, new[] { _sqlTable }, null, sqlGroupExpression, new Ordering[] { }, null, false, null, null); _stageMock.Expect( mock => mock.GenerateTextForSelectExpression(_commandBuilder, sqlStatement.SelectProjection)) .WhenCalled(mi => ((SqlCommandBuilder)mi.Arguments[0]).Append("[t].[ID],[t].[Name],[t].[City]")); _stageMock.Expect(mock => mock.GenerateTextForFromTable(_commandBuilder, sqlStatement.SqlTables[0], true)) .WhenCalled(mi => ((SqlCommandBuilder)mi.Arguments[0]).Append("[Table] AS [t]")); _stageMock.Expect( mock => mock.GenerateTextForGroupByExpression(_commandBuilder, sqlStatement.GroupByExpression)) .WhenCalled(mi => ((SqlCommandBuilder)mi.Arguments[0]).Append("keyExpression")); _stageMock.Replay(); _generator.Build(sqlStatement, _commandBuilder, false); _stageMock.VerifyAllExpectations(); Assert.That(_commandBuilder.GetCommandText(), Is.EqualTo("SELECT [t].[ID],[t].[Name],[t].[City] FROM [Table] AS [t] GROUP BY keyExpression")); }
public void GenerateSql_Collection_Grouping() { var expression = SqlStatementModelObjectMother.CreateSqlGroupingSelectExpression(); SqlGeneratingSelectExpressionVisitor.GenerateSql(expression, _commandBuilder, _stageMock); Assert.That(_commandBuilder.GetCommandText(), Is.EqualTo("@1")); }
public void ResolveMemberAccess_OnGroupingSelectExpression() { var expression = SqlStatementModelObjectMother.CreateSqlGroupingSelectExpression(); var memberInfo = typeof(IGrouping <string, string>).GetProperty("Key"); var result = MemberAccessResolver.ResolveMemberAccess(expression, memberInfo, _resolverMock, _stageMock, _mappingResolutionContext); Assert.That(result, Is.SameAs(expression.KeyExpression)); }
public void SetUp() { _sqlStatement = new SqlStatementBuilder(SqlStatementModelObjectMother.CreateSqlStatement_Resolved(typeof(Cook))) { SelectProjection = new NamedExpression("test", Expression.Constant(5)), DataInfo = new StreamedSequenceInfo(typeof(int[]), Expression.Constant(0)) }.GetSqlStatement(); _tableInfo = new ResolvedJoinedGroupingTableInfo( "q0", _sqlStatement, SqlStatementModelObjectMother.CreateSqlGroupingSelectExpression(), "q1"); }
public void GenerateTextForGroupByExpression() { var expression = SqlStatementModelObjectMother.CreateSqlGroupingSelectExpression(); var stageMock = MockRepository.GeneratePartialMock <DefaultSqlGenerationStage>(); stageMock .Expect(mock => CallGenerateTextForNonSelectExpression(mock, expression)) .WhenCalled(c => _commandBuilder.Append("GROUP BY keyExpression")); stageMock.Replay(); stageMock.GenerateTextForGroupByExpression(_commandBuilder, expression); stageMock.VerifyAllExpectations(); Assert.That(_commandBuilder.GetCommandText(), Is.EqualTo("GROUP BY keyExpression")); }
public void VisitSqlGroupingSelectExpression() { var expression = SqlStatementModelObjectMother.CreateSqlGroupingSelectExpression(); _visitor.VisitSqlGroupingSelectExpression(expression); }