SqlColumnExpression represents a sql-specific column expression.
Inheritance: Remotion.Linq.Clauses.Expressions.ExtensionExpression
 public void SetUp ()
 {
   _columnExpression1 = new SqlColumnDefinitionExpression (typeof (int), "t", "ID", true);
   _columnExpression2 = new SqlColumnDefinitionExpression (typeof (int), "t", "Name", false);
   _columnExpression3 = new SqlColumnDefinitionExpression (typeof (int), "t", "City", false);
   _orginalColumns = new[] { _columnExpression1, _columnExpression2, _columnExpression3 };
   _entityExpression = new SqlEntityDefinitionExpression (typeof (Cook), "t", null, e => e.GetColumn (typeof (int), "ID", true), _orginalColumns);
   _originalColumnsReadonly = _entityExpression.Columns;
 }
 Expression IResolvedSqlExpressionVisitor.VisitSqlColumnExpression (SqlColumnExpression expression)
 {
   throw new InvalidOperationException ("SqlColumnExpression is not valid at this point. (Must be wrapped within a NamedExpression.)");
 }
 public Expression VisitSqlColumnExpression (SqlColumnExpression expression)
 {
   // We always need to convert boolean columns to int columns because in the database, the column is represented as a bit (integer) value
   if (BooleanUtility.IsBooleanType (expression.Type))
   {
     var intType = BooleanUtility.GetMatchingIntType (expression.Type);
     Expression convertedExpression = expression.Update (intType, expression.OwningTableAlias, expression.ColumnName, expression.IsPrimaryKey);
     return new SqlConvertedBooleanExpression (convertedExpression);
   }
   
   return expression; // rely on VisitExpression to apply correct semantics
 }
 public Expression ResolveMemberExpression (SqlColumnExpression sqlColumnExpression, MemberInfo memberInfo)
 {
   throw new NotSupportedException (string.Format ("Member '{0}' applied to column '{1}' is not supported.", memberInfo.Name, sqlColumnExpression));
 }
 protected override void AppendColumnForEntity (SqlEntityExpression entity, SqlColumnExpression column)
 {
   column.Accept (this);
   
   string alias = GetAliasForColumnOfEntity(column, entity);
   if (alias != null)
   {
     CommandBuilder.Append (" AS ");
     CommandBuilder.AppendIdentifier (alias);
   }
 }
 protected string GetAliasForColumnOfEntity (SqlColumnExpression column, SqlEntityExpression entity)
 {
   if (column.ColumnName != "*")
   {
     if (entity.Name != null)
     {
       return entity.Name + "_" + column.ColumnName;
     }
     else if ((entity is SqlEntityReferenceExpression) && ((SqlEntityReferenceExpression) entity).ReferencedEntity.Name != null)
     {
       // entity references without a name that point to an entity with a name must assign aliases to their columns;
       // otherwise, their columns would include the referenced entity's name
       return column.ColumnName;
     }
   }
   return null;
 }
    private static string GetColumnType (SqlColumnExpression c)
    {
      var sqlTypeName = SqlConvertExpression.GetSqlTypeName (c.Type);
      // (MAX) types are not valid in primary key columns.
      if (c.IsPrimaryKey)
        return sqlTypeName.Replace ("(MAX)", "(100)");

      return sqlTypeName;
    }