DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
SelectStatement.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 using System.Collections.Generic;
19 
22 using Deveel.Data.Sql.Query;
23 
24 namespace Deveel.Data.Sql.Statements {
26  public SelectStatement(SqlQueryExpression queryExpression)
27  : this(queryExpression, null) {
28  }
29 
30  public SelectStatement(SqlQueryExpression queryExpression, IEnumerable<SortColumn> orderBy) {
31  if (queryExpression == null)
32  throw new ArgumentNullException("queryExpression");
33 
34  QueryExpression = queryExpression;
35  OrderBy = orderBy;
36  }
37 
38  public SqlQueryExpression QueryExpression { get; private set; }
39 
40  public IEnumerable<SortColumn> OrderBy { get; set; }
41 
42  public QueryLimit Limit { get; set; }
43 
45  var queryPlan = context.Query.Context.QueryPlanner().PlanQuery(new QueryInfo(context, QueryExpression, OrderBy, Limit));
46  return new Prepared(queryPlan);
47  }
48 
49  #region Prepared
50 
51  [Serializable]
53  public Prepared(IQueryPlanNode queryPlan) {
54  QueryPlan = queryPlan;
55  }
56 
57  private Prepared(ObjectData data) {
58  QueryPlan = data.GetValue<IQueryPlanNode>("QueryPlan");
59  }
60 
61  public IQueryPlanNode QueryPlan { get; private set; }
62 
63  protected override void GetData(SerializeData data) {
64  data.SetValue("QueryPlan", QueryPlan);
65  }
66 
67  protected override void ExecuteStatement(ExecutionContext context) {
68  var result = QueryPlan.Evaluate(context.Request);
69  context.SetResult(result);
70  }
71  }
72 
73  #endregion
74  }
75 }
SelectStatement(SqlQueryExpression queryExpression, IEnumerable< SortColumn > orderBy)
void SetValue(string key, Type type, object value)
SelectStatement(SqlQueryExpression queryExpression)
A node element of a query plan tree. /summary>
Represents the foundation class of SQL statements to be executed.
Definition: SqlStatement.cs:32
override void ExecuteStatement(ExecutionContext context)
new IQueryContext Context
Definition: IQuery.cs:21