DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Classes | Public Member Functions | Properties | Private Attributes | List of all members
Deveel.Data.Transactions.Transaction.OldAndNewTableContainer Class Reference
Inheritance diagram for Deveel.Data.Transactions.Transaction.OldAndNewTableContainer:
Deveel.Data.Sql.Tables.ITableContainer

Classes

class  TriggeredOldNew
 

Public Member Functions

 OldAndNewTableContainer (Transaction transaction)
 
int FindByName (ObjectName name)
 Finds the index in this container of the given table by its name. More...
 
ObjectName GetTableName (int offset)
 Gets the name of the table at the given index in this container. More...
 
TableInfo GetTableInfo (int offset)
 Gets the information of the table at the given offset in this container. More...
 
string GetTableType (int offset)
 Gets the type of the table at the given offset. More...
 
bool ContainsTable (ObjectName name)
 Checks if a table with the given name is contained in the current context. More...
 
ITable GetTable (int offset)
 Gets the table contained at the given offset within the context. More...
 

Properties

bool HasOldTable [get]
 
bool HasNewTable [get]
 
int TableCount [get]
 
- Properties inherited from Deveel.Data.Sql.Tables.ITableContainer
int TableCount [get]
 Returns the total count of tables that this object is maintaining. More...
 

Private Attributes

readonly Transaction transaction
 

Detailed Description

Definition at line 345 of file Transaction.cs.

Constructor & Destructor Documentation

Deveel.Data.Transactions.Transaction.OldAndNewTableContainer.OldAndNewTableContainer ( Transaction  transaction)
inline

Definition at line 348 of file Transaction.cs.

348  {
349  this.transaction = transaction;
350  }

Member Function Documentation

bool Deveel.Data.Transactions.Transaction.OldAndNewTableContainer.ContainsTable ( ObjectName  name)
inline

Checks if a table with the given name is contained in the current context.

Parameters
nameThe name of the table to search.
Returns
Returns true if any table with the given name was found in the container, false otherwise.

Implements Deveel.Data.Sql.Tables.ITableContainer.

Definition at line 398 of file Transaction.cs.

398  {
399  return FindByName(name) > 0;
400  }
int FindByName(ObjectName name)
Finds the index in this container of the given table by its name.
Definition: Transaction.cs:372
int Deveel.Data.Transactions.Transaction.OldAndNewTableContainer.FindByName ( ObjectName  name)
inline

Finds the index in this container of the given table by its name.

Parameters
nameThe name of the table to find.
Returns
Returns a zero-based index that represents the offset of the table identified by the given name within the context, ot -1 of not found.

Implements Deveel.Data.Sql.Tables.ITableContainer.

Definition at line 372 of file Transaction.cs.

372  {
373  if (HasOldTable &&
374  name.Equals(SystemSchema.OldTriggerTableName, transaction.IgnoreIdentifiersCase()))
375  return 0;
376  if (HasNewTable &&
377  name.Equals(SystemSchema.NewTriggerTableName, transaction.IgnoreIdentifiersCase()))
378  return HasOldTable ? 1 : 0;
379  return -1;
380  }
override bool Equals(object obj)
Definition: ObjectName.cs:241
ITable Deveel.Data.Transactions.Transaction.OldAndNewTableContainer.GetTable ( int  offset)
inline

Gets the table contained at the given offset within the context.

Parameters
offsetThe zero-based offset of the table to return.
Returns
Returns an instance of ITable that provides access to the backed informaion for an object provided by the context.
Exceptions
ArgumentOutOfRangeExceptionIf the given offset is smaller than 0 or greater or equal than TableCount.

Implements Deveel.Data.Sql.Tables.ITableContainer.

Definition at line 402 of file Transaction.cs.

402  {
403  var tableInfo = GetTableInfo(offset);
404 
405  var table = new TriggeredOldNew(transaction.DatabaseContext, tableInfo);
406 
407  if (HasOldTable) {
408  if (offset == 0) {
409  // Copy data from the table to the new table
410  var dtable = transaction.GetTable(transaction.TableState.TableSource);
411  var oldRow = new Row(table);
412  int rowIndex = transaction.TableState.OldRowIndex;
413  for (int i = 0; i < tableInfo.ColumnCount; ++i) {
414  oldRow.SetValue(i, dtable.GetValue(rowIndex, i));
415  }
416 
417  // All OLD tables are immutable
418  table.SetReadOnly(true);
419  table.SetData(oldRow);
420 
421  return table;
422  }
423  }
424 
425  table.SetReadOnly(!transaction.TableState.IsNewMutable);
426  table.SetData(transaction.TableState.NewDataRow);
427 
428  return table;
429  }
A single row in a table of a database.
Definition: Row.cs:44
TableInfo GetTableInfo(int offset)
Gets the information of the table at the given offset in this container.
Definition: Transaction.cs:389
TableInfo Deveel.Data.Transactions.Transaction.OldAndNewTableContainer.GetTableInfo ( int  offset)
inline

Gets the information of the table at the given offset in this container.

Parameters
offsetThe zero-based offset of the table whose information to return.
Returns
Returns an instance of
See also
TableInfo
that describes the metadata of a table at the given offset within the context.
Exceptions
ArgumentOutOfRangeExceptionIf the given offset is smaller than 0 or greater or equal than TableCount.

Implements Deveel.Data.Sql.Tables.ITableContainer.

Definition at line 389 of file Transaction.cs.

389  {
390  var tableInfo = transaction.GetTableInfo(transaction.TableState.TableSource);
391  return tableInfo.Alias(GetTableName(offset));
392  }
ObjectName GetTableName(int offset)
Gets the name of the table at the given index in this container.
Definition: Transaction.cs:382
ObjectName Deveel.Data.Transactions.Transaction.OldAndNewTableContainer.GetTableName ( int  offset)
inline

Gets the name of the table at the given index in this container.

Parameters
offsetThe zero-based offset of the table whose name to return.
Returns
Returns a
See also
ObjectName
that identifies the table.
Exceptions
ArgumentOutOfRangeExceptionIf the given offset is smaller than 0 or greater or equal than TableCount.

Implements Deveel.Data.Sql.Tables.ITableContainer.

Definition at line 382 of file Transaction.cs.

382  {
383  if (HasOldTable && offset == 0)
384  return SystemSchema.OldTriggerTableName;
385 
386  return SystemSchema.NewTriggerTableName;
387  }
string Deveel.Data.Transactions.Transaction.OldAndNewTableContainer.GetTableType ( int  offset)
inline

Gets the type of the table at the given offset.

Parameters
offsetThe zero-based offset of the table whose type to return.
Returns
Returns a String that describes the type of table at the given offset.
Exceptions
ArgumentOutOfRangeExceptionIf the given offset is smaller than 0 or greater or equal than TableCount.

Implements Deveel.Data.Sql.Tables.ITableContainer.

Definition at line 394 of file Transaction.cs.

394  {
395  return TableTypes.SystemTable;
396  }

Member Data Documentation

readonly Transaction Deveel.Data.Transactions.Transaction.OldAndNewTableContainer.transaction
private

Definition at line 346 of file Transaction.cs.

Property Documentation

bool Deveel.Data.Transactions.Transaction.OldAndNewTableContainer.HasNewTable
getprivate

Definition at line 356 of file Transaction.cs.

bool Deveel.Data.Transactions.Transaction.OldAndNewTableContainer.HasOldTable
getprivate

Definition at line 352 of file Transaction.cs.

int Deveel.Data.Transactions.Transaction.OldAndNewTableContainer.TableCount
get

Definition at line 361 of file Transaction.cs.


The documentation for this class was generated from the following file: