Exemplo n.º 1
0
 public virtual ProjectionExpression AddOuterJoinTest(ProjectionExpression proj)
 {
     var test = this.GetOuterJoinTest(proj.Select);
     var select = proj.Select;
     FieldExpression testCol = null;
     // look to see if test expression exists in fields already
     foreach (var col in select.Fields)
     {
         if (test.Equals(col.Expression))
         {
             var colType = this.TypeSystem.GetStorageType(test.Type);
             testCol = new FieldExpression(test.Type, colType, select.Alias, col.Name);
             break;
         }
     }
     if (testCol == null)
     {
         // add expression to projection
         testCol = test as FieldExpression;
         string colName = (testCol != null) ? testCol.Name : "Test";
         colName = proj.Select.Fields.GetAvailableFieldName(colName);
         var colType = this.TypeSystem.GetStorageType(test.Type);
         select = select.AddField(new FieldDeclaration(colName, test, colType));
         testCol = new FieldExpression(test.Type, colType, select.Alias, colName);
     }
     var newProjector = new OuterJoinedExpression(testCol, proj.Projector);
     return new ProjectionExpression(select, newProjector, proj.Aggregator);
 }
Exemplo n.º 2
0
 public static ProjectionExpression AddOuterJoinTest(this ProjectionExpression proj, QueryLanguage language, Expression expression)
 {
     string colName = proj.Select.Fields.GetAvailableFieldName("Test");
     var colType = language.TypeSystem.GetStorageType(expression.Type);
     SelectExpression newSource = proj.Select.AddField(new FieldDeclaration(colName, expression, colType));
     Expression newProjector =
         new OuterJoinedExpression(
             new FieldExpression(expression.Type, colType, newSource.Alias, colName),
             proj.Projector
             );
     return new ProjectionExpression(newSource, newProjector, proj.Aggregator);
 }
Exemplo n.º 3
0
 protected virtual Expression VisitOuterJoined(OuterJoinedExpression outer)
 {
     var test = this.Visit(outer.Test);
     var expression = this.Visit(outer.Expression);
     return this.UpdateOuterJoined(outer, test, expression);
 }
Exemplo n.º 4
0
 protected OuterJoinedExpression UpdateOuterJoined(OuterJoinedExpression outer, Expression test, Expression expression)
 {
     if (test != outer.Test || expression != outer.Expression)
     {
         return new OuterJoinedExpression(test, expression);
     }
     return outer;
 }
Exemplo n.º 5
0
 protected virtual Expression VisitOuterJoined(OuterJoinedExpression outer)
 {
     this.Write("Outer(");
     this.WriteLine(Indentation.Inner);
     this.Visit(outer.Test);
     this.Write(", ");
     this.WriteLine(Indentation.Same);
     this.Visit(outer.Expression);
     this.WriteLine(Indentation.Outer);
     this.Write(")");
     return outer;
 }