public virtual ProjectionExpression AddOuterJoinTest(ProjectionExpression proj) { Expression test = GetOuterJoinTest(proj.Select); SelectExpression select = proj.Select; ColumnExpression testCol = null; // look to see if test expression exists in columns already foreach (ColumnDeclaration col in select.Columns) { if (test.Equals(col.Expression)) { QueryType colType = TypeSystem.GetColumnType(test.Type); testCol = new ColumnExpression(test.Type, colType, select.Alias, col.Name); break; } } if (testCol == null) { // add expression to projection testCol = test as ColumnExpression; string colName = (testCol != null) ? testCol.Name : "Test"; colName = proj.Select.Columns.GetAvailableColumnName(colName); QueryType colType = TypeSystem.GetColumnType(test.Type); select = select.AddColumn(new ColumnDeclaration(colName, test, colType)); testCol = new ColumnExpression(test.Type, colType, select.Alias, colName); } var newProjector = new OuterJoinedExpression(testCol, proj.Projector); return(new ProjectionExpression(select, newProjector, proj.Aggregator)); }
internal virtual DbProjectionExpression AddOuterJoinTest(DbProjectionExpression proj) { var test = this.GetOuterJoinTest(proj.Select); var select = proj.Select; var testCol = null as DbColumnExpression; foreach (var col in select.Columns) { if (test.Equals(col.Expression)) { testCol = new DbColumnExpression(test.Type, TypeSystem.GetColumnType(test.Type), select.Alias, col.Name); break; } } if (testCol == null) { testCol = test as DbColumnExpression; var colName = testCol != null ? testCol.Name : "Test"; if (colName != null) { colName = proj.Select.Columns.GetAvailableColumnName(colName); } var colType = this.TypeSystem.GetColumnType(test.Type); if (colType != null) { select = select.AddColumn(new DbColumnDeclaration(colName, test, colType)); testCol = new DbColumnExpression(test.Type, colType, select.Alias, colName); } } return(new DbProjectionExpression ( select, new DbOuterJoinedExpression(testCol, proj.Projector), proj.Aggregator )); }