DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
FetchContext.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;
21 
22 namespace Deveel.Data.Sql.Cursors {
23  public sealed class FetchContext {
24  private int offset;
25 
26  public FetchContext(IRequest request, SqlExpression reference)
27  : this(request, FetchDirection.Next, reference) {
28  }
29 
30  public FetchContext(IRequest request, FetchDirection direction, SqlExpression reference) {
31  if (request == null)
32  throw new ArgumentNullException("request");
33  if (reference == null)
34  throw new ArgumentNullException("reference");
35 
36  if (reference.ExpressionType != SqlExpressionType.VariableReference &&
37  reference.ExpressionType != SqlExpressionType.Reference)
38  throw new ArgumentException("Invalid reference expression type.");
39 
40  Request = request;
41  Direction = direction;
42  Reference = reference;
43  }
44 
45  public FetchDirection Direction { get; private set; }
46 
47  public SqlExpression Reference { get; set; }
48 
49  public bool IsVariableReference {
50  get { return Reference.ExpressionType == SqlExpressionType.VariableReference; }
51  }
52 
53  public bool IsGlobalReference {
54  get { return Reference.ExpressionType == SqlExpressionType.Reference; }
55  }
56 
57  public IRequest Request { get; private set; }
58 
59  public int Offset {
60  get { return offset; }
61  set {
62  if (Direction != FetchDirection.Absolute &&
63  Direction != FetchDirection.Relative)
64  throw new ArgumentException("Cannot set offset for this direction.");
65 
66  offset = value;
67  }
68  }
69  }
70 }
SqlExpressionType
All the possible type of SqlExpression supported
FetchContext(IRequest request, FetchDirection direction, SqlExpression reference)
Definition: FetchContext.cs:30
An expression that references an object on the database (that is a Column, Table, Sequence...
Defines the base class for instances that represent SQL expression tree nodes.
abstract SqlExpressionType ExpressionType
Gets the type code of this SQL expression.
FetchContext(IRequest request, SqlExpression reference)
Definition: FetchContext.cs:26