DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
JoinNode.cs
Go to the documentation of this file.
1 //
2 // Copyright 2010-2015 Deveel
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 using System;
18 
19 using Deveel.Data;
22 using Deveel.Data.Sql.Tables;
23 
24 namespace Deveel.Data.Sql.Query {
25  [Serializable]
27  public JoinNode(IQueryPlanNode left, IQueryPlanNode right, ObjectName leftColumnName, SqlExpressionType @operator, SqlExpression rightExpression)
28  : base(left, right) {
29  LeftColumnName = leftColumnName;
30  Operator = @operator;
31  RightExpression = rightExpression;
32  }
33 
34  private JoinNode(ObjectData data)
35  : base(data) {
36  LeftColumnName = data.GetValue<ObjectName>("LeftColumn");
37  Operator = (SqlExpressionType) data.GetInt32("Operator");
38  RightExpression = data.GetValue<SqlExpression>("RightExpression");
39  }
40 
41  public ObjectName LeftColumnName { get; private set; }
42 
43  public SqlExpressionType Operator { get; private set; }
44 
45  public SqlExpression RightExpression { get; private set; }
46 
47  public override ITable Evaluate(IRequest context) {
48  // Solve the left branch result
49  var leftResult = Left.Evaluate(context);
50  // Solve the right branch result
51  var rightResult = Right.Evaluate(context);
52 
53  return leftResult.Join(context, rightResult, LeftColumnName, Operator, RightExpression);
54  }
55 
56  protected override void GetData(SerializeData data) {
57  data.SetValue("LeftColumn", LeftColumnName);
58  data.SetValue("Operator", (int)Operator);
59  data.SetValue("RightExpression", RightExpression);
60  }
61  }
62 }
override ITable Evaluate(IRequest context)
Definition: JoinNode.cs:47
JoinNode(IQueryPlanNode left, IQueryPlanNode right, ObjectName leftColumnName, SqlExpressionType @operator, SqlExpression rightExpression)
Definition: JoinNode.cs:27
override void GetData(SerializeData data)
Definition: JoinNode.cs:56
Defines the contract to access the data contained into a table of a database.
Definition: ITable.cs:40
void SetValue(string key, Type type, object value)
Describes the name of an object within a database.
Definition: ObjectName.cs:44
SqlExpressionType
All the possible type of SqlExpression supported
A node element of a query plan tree. /summary>
Returns all the records in the left side of the join, even if the other side has no corresponding rec...
Returns all the records in the right side of the join, even if the other side has no corresponding re...
A IQueryPlanNode implementation that is a branch with two child nodes.
Defines the base class for instances that represent SQL expression tree nodes.
JoinNode(ObjectData data)
Definition: JoinNode.cs:34