DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
SqlTabular.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;
19 using System.Collections.Generic;
20 
21 using Deveel.Data;
22 using Deveel.Data.Index;
23 
24 namespace Deveel.Data.Sql.Objects {
25  public sealed class SqlTabular : ITable, ISqlObject {
26  private ITable table;
27 
28  private SqlTabular(ITable table) {
29  this.table = table;
30  }
31 
32  int IComparable.CompareTo(object obj) {
33  throw new NotSupportedException();
34  }
35 
36  int IComparable<ISqlObject>.CompareTo(ISqlObject other) {
37  throw new NotSupportedException();
38  }
39 
40  public bool IsNull {
41  get { return table == null; }
42  }
43 
44  private void AssertNotNull() {
45  if (table == null)
46  throw new NullReferenceException("The object is null.");
47  }
48 
50  return false;
51  }
52 
53  public static SqlTabular From(ITable table) {
54  return new SqlTabular(table);
55  }
56 
58  get {
59  AssertNotNull();
60  return table.FullName;
61  }
62  }
63 
65  get { return DbObjectType.Table; }
66  }
67 
68  public IEnumerator<Row> GetEnumerator() {
69  AssertNotNull();
70  return table.GetEnumerator();
71  }
72 
73  IEnumerator IEnumerable.GetEnumerator() {
74  return GetEnumerator();
75  }
76 
77  public void Dispose() {
78  table = null;
79  }
80 
81  IDatabaseContext ITable.DatabaseContext {
82  get {
83  AssertNotNull();
84  return table.DatabaseContext;
85  }
86  }
87 
88  TableInfo ITable.TableInfo {
89  get {
90  AssertNotNull();
91  return table.TableInfo;
92  }
93  }
94 
95  public int RowCount {
96  get {
97  AssertNotNull();
98  return table.RowCount;
99  }
100  }
101 
102  public DataObject GetValue(long rowNumber, int columnOffset) {
103  AssertNotNull();
104  return table.GetValue(rowNumber, columnOffset);
105  }
106 
107  ColumnIndex ITable.GetIndex(int columnOffset) {
108  AssertNotNull();
109  return table.GetIndex(columnOffset);
110  }
111  }
112 }
IEnumerator< Row > GetEnumerator()
Definition: SqlTabular.cs:68
The context of a single database within a system.
Represents a database object, such as a table, a trigger, a type or a column.
Definition: IDbObject.cs:24
ObjectName FullName
Gets the fully qualified name of the object used to resolve it uniquely within the database...
Definition: IDbObject.cs:30
Describes the name of an object within a database.
Definition: ObjectName.cs:44
DataObject GetValue(long rowNumber, int columnOffset)
Definition: SqlTabular.cs:102
Defines the contract for a valid SQL Object
Definition: ISqlObject.cs:23
static SqlTabular From(ITable table)
Definition: SqlTabular.cs:53
Represents a dynamic object that encapsulates a defined SqlType and a compatible constant ISqlObject ...
Definition: DataObject.cs:35
DbObjectType ObjectType
Gets the type of database object that the implementation is for
Definition: IDbObject.cs:35
bool IsComparableTo(ISqlObject other)
Checks if the current object is comparable with the given one.
DbObjectType
The kind of objects that can be handled by a database system and its managers
Definition: DbObjectType.cs:27