public void GenerateSql_Collection_Grouping() { var expression = SqlStatementModelObjectMother.CreateSqlGroupingSelectExpression(); SqlGeneratingSelectExpressionVisitor.GenerateSql(expression, _commandBuilder, _stageMock); Assert.That(_commandBuilder.GetCommandText(), Is.EqualTo("@1")); }
public void GenerateTextForSelectExpression_CollectionInSelectProjection_StringsNotDetectedAsCollections() { var expression = Expression.Constant("test"); SqlGeneratingSelectExpressionVisitor.GenerateSql(expression, _commandBuilder, _stageMock); Assert.That(_commandBuilder.GetCommandText(), Is.EqualTo("@1")); }
public void VisitNamedExpression_NameIsNotNull() { var columnExpression = new SqlColumnDefinitionExpression(typeof(string), "c", "Name", false); var expression = new NamedExpression("test", columnExpression); SqlGeneratingSelectExpressionVisitor.GenerateSql(expression, _commandBuilder, _stageMock); Assert.That(_commandBuilder.GetCommandText(), Is.EqualTo("[c].[Name] AS [test]")); }
public void VisitSqlGroupingSelectExpression_WithoutAggregationExpressions() { var groupingExpression = new SqlGroupingSelectExpression(Expression.Constant("keyExpression"), Expression.Constant("elementExpression")); SqlGeneratingSelectExpressionVisitor.GenerateSql(groupingExpression, _commandBuilder, _stageMock); Assert.That(_commandBuilder.GetCommandText(), Is.EqualTo("@1")); Assert.That(_commandBuilder.GetCommandParameters()[0].Value, Is.EqualTo("keyExpression")); }
public void VisitSqlGroupingSelectExpression_WithAggregationExpressions_AndNames() { var groupingExpression = SqlGroupingSelectExpression.CreateWithNames(Expression.Constant("keyExpression"), Expression.Constant("elementExpression")); groupingExpression.AddAggregationExpressionWithName(Expression.Constant("aggregation1")); groupingExpression.AddAggregationExpressionWithName(Expression.Constant("aggregation2")); SqlGeneratingSelectExpressionVisitor.GenerateSql(groupingExpression, _commandBuilder, _stageMock); Assert.That(_commandBuilder.GetCommandText(), Is.EqualTo("@1 AS [key], @2 AS [a0], @3 AS [a1]")); Assert.That(_commandBuilder.GetCommandParameters()[0].Value, Is.EqualTo("keyExpression")); Assert.That(_commandBuilder.GetCommandParameters()[1].Value, Is.EqualTo("aggregation1")); Assert.That(_commandBuilder.GetCommandParameters()[2].Value, Is.EqualTo("aggregation2")); }
public void GenerateSql_VisitSqlEntityExpression_NamedEntity_StarColumn() { var sqlColumnListExpression = new SqlEntityDefinitionExpression( typeof(string), "t", "Test", e => e.GetColumn(typeof(int), "ID", true), new[] { new SqlColumnDefinitionExpression(typeof(string), "t", "*", false) }); SqlGeneratingSelectExpressionVisitor.GenerateSql(sqlColumnListExpression, _commandBuilder, _stageMock); Assert.That(_commandBuilder.GetCommandText(), Is.EqualTo("[t].*")); }
public void GenerateSql_VisitSqlEntityExpression_NamedEntity_ReferencingNamed() { var referencedEntity = new SqlEntityDefinitionExpression( typeof(Cook), "c", "Cook", e => e, new[] { new SqlColumnDefinitionExpression(typeof(string), "t", "Name", false), new SqlColumnDefinitionExpression(typeof(string), "t", "City", false) }); var entityExpression = new SqlEntityReferenceExpression(typeof(Cook), "c", "ref", referencedEntity); SqlGeneratingSelectExpressionVisitor.GenerateSql(entityExpression, _commandBuilder, _stageMock); Assert.That(_commandBuilder.GetCommandText(), Is.EqualTo("[c].[Cook_Name] AS [ref_Name],[c].[Cook_City] AS [ref_City]")); }
public void GenerateSql_VisitSqlEntityExpression_UnnamedEntity() { var sqlColumnListExpression = new SqlEntityDefinitionExpression( typeof(string), "t", null, e => e, new[] { new SqlColumnDefinitionExpression(typeof(string), "t", "ID", true), new SqlColumnDefinitionExpression(typeof(string), "t", "Name", false), new SqlColumnDefinitionExpression(typeof(string), "t", "City", false) }); SqlGeneratingSelectExpressionVisitor.GenerateSql( sqlColumnListExpression, _commandBuilder, _stageMock); Assert.That(_commandBuilder.GetCommandText(), Is.EqualTo("[t].[ID],[t].[Name],[t].[City]")); }
public void GenerateSql_Collection() { var expression = Expression.Constant(new Cook[] { }); SqlGeneratingSelectExpressionVisitor.GenerateSql(expression, _commandBuilder, _stageMock); }