DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
GeneratedTable.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.Index;
22 using Deveel.Data.Sql.Objects;
23 
24 namespace Deveel.Data.Sql.Tables {
25  abstract class GeneratedTable : ITable {
26  protected GeneratedTable(IContext dbContext) {
27  Context = dbContext;
28  }
29 
31  Dispose(false);
32  }
33 
34  public IContext Context { get; private set; }
35 
37  get { return TableInfo.TableName; }
38  }
39 
41  get { return DbObjectType.Table; }
42  }
43 
44  public IEnumerator<Row> GetEnumerator() {
45  return new SimpleRowEnumerator(this);
46  }
47 
48  IEnumerator IEnumerable.GetEnumerator() {
49  return GetEnumerator();
50  }
51 
52  public abstract TableInfo TableInfo { get; }
53 
54  public abstract int RowCount { get; }
55 
56  public abstract DataObject GetValue(long rowNumber, int columnOffset);
57 
58  public virtual ColumnIndex GetIndex(int columnOffset) {
59  return new BlindSearchIndex(this, columnOffset);
60  }
61 
62  protected DataObject GetColumnValue(int column, ISqlObject obj) {
63  var type = TableInfo[column].ColumnType;
64  return new DataObject(type, obj);
65  }
66 
67  public void Dispose() {
68  Dispose(true);
69  GC.SuppressFinalize(this);
70  }
71 
72  protected virtual void Dispose(bool disposing) {
73  Context = null;
74  }
75  }
76 }
Defines the contract to access the data contained into a table of a database.
Definition: ITable.cs:40
virtual void Dispose(bool disposing)
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
ObjectName TableName
Gets the fully qualified name of the table that is ensured to be unique within the system...
Definition: TableInfo.cs:97
Defines the contract for a valid SQL Object
Definition: ISqlObject.cs:23
DataObject GetColumnValue(int column, ISqlObject obj)
Represents a dynamic object that encapsulates a defined SqlType and a compatible constant ISqlObject ...
Definition: DataObject.cs:35
virtual ColumnIndex GetIndex(int columnOffset)
Gets an index for given column that can be used to select values from this table. ...
DbObjectType ObjectType
Gets the type of database object that the implementation is for
Definition: IDbObject.cs:35
DbObjectType
The kind of objects that can be handled by a database system and its managers
Definition: DbObjectType.cs:27
Defines the metadata properties of a table existing within a database.
Definition: TableInfo.cs:41