Defines a SQL column as a reference to a column of a SqlEntityExpression. The column is represented as [alias].[entityname_name]. This is used to reference columns of entities defined by substatements, e.g., in from x in (from c in Cooks select c).Distinct() select x.FirstName; x.FirstName is a column that references the entity defined by the substatement.
Inheritance: SqlColumnExpression
    public void GenerateSql_VisitSqlColumnReferenceExpression_WithNamedEntity ()
    {
      var entityExpression = SqlStatementModelObjectMother.CreateSqlEntityDefinitionExpression (typeof (Cook), "Test");
      var sqlColumnExpression = new SqlColumnReferenceExpression (typeof (int), "s", "ID", false, entityExpression);
      SqlGeneratingExpressionVisitor.GenerateSql (sqlColumnExpression, _commandBuilder, _stageMock);

      Assert.That (_commandBuilder.GetCommandText(), Is.EqualTo ("[s].[Test_ID]"));
    }
    public void ToString_WithEntityName ()
    {
      var referencedEntity = SqlStatementModelObjectMother.CreateSqlEntityDefinitionExpression (typeof (Cook), "e1");
      var columnExpression = new SqlColumnReferenceExpression (typeof (int), "t0", "ID", true, referencedEntity);
      var result = columnExpression.ToString ();

      Assert.That (result, Is.EqualTo ("[t0].[e1_ID] (REF)"));
    }
    public void Update ()
    {
      var result = _columnExpression.Update (typeof (char), "f", "test", false);

      var expectedResult = new SqlColumnReferenceExpression (typeof (char), "f", "test", false, _entityExpression);

      SqlExpressionTreeComparer.CheckAreEqualTrees (result, expectedResult);
    }
    public void Initialize ()
    {
      var entityReferenceExpression = new SqlEntityReferenceExpression (typeof (Cook), "t", null, _entityDefinitionExpression);

      var expectedColumn = new SqlColumnReferenceExpression (typeof (string), "t", "Name", false, _entityDefinitionExpression);
      SqlExpressionTreeComparer.CheckAreEqualTrees (expectedColumn, entityReferenceExpression.Columns[0]);

      Assert.That (entityReferenceExpression.IdentityExpressionGenerator, Is.SameAs (_entityDefinitionExpression.IdentityExpressionGenerator));
    }
    public void GetColumn ()
    {
      var entityReferenceExpression = new SqlEntityReferenceExpression (typeof (Cook), "t", null, _entityDefinitionExpression);

      var result = entityReferenceExpression.GetColumn (typeof (string), "Test", false);

      var exprectedresult = new SqlColumnReferenceExpression (typeof (string), "t", "Test", false, _entityDefinitionExpression);

      SqlExpressionTreeComparer.CheckAreEqualTrees (exprectedresult, result);
    }
    public void GenerateSql_VisitSqlColumnReferenceExpression_WithNamedEntity_WithStarColumn ()
    {
      var entityExpression = new SqlEntityDefinitionExpression (
          typeof (Cook),
          "c",
          "Test",
          e => e.GetColumn (typeof (int), "ID", true),
          new SqlColumnDefinitionExpression (typeof (Cook), "c", "*", false));
      var sqlColumnExpression = new SqlColumnReferenceExpression (typeof (int), "s", "ID", false, entityExpression);

      SqlGeneratingExpressionVisitor.GenerateSql (sqlColumnExpression, _commandBuilder, _stageMock);

      Assert.That (_commandBuilder.GetCommandText(), Is.EqualTo ("[s].[ID]"));
    }
 public void SetUp ()
 {
   _entityExpression = SqlStatementModelObjectMother.CreateSqlEntityDefinitionExpression();
   _columnExpression = new SqlColumnReferenceExpression (typeof (string), "c", "columnName", false, _entityExpression);
 }