Table of Contents

Class MemTable

Namespace
Tripous.Data
Assembly
Tripous.Data.dll

An extended DataTable

public class MemTable : DataTable, IComponent, IDisposable, IServiceProvider, IListSource, ISupportInitializeNotification, ISupportInitialize, ISerializable, IXmlSerializable, IRowProvider, IRowProviderHost
Inheritance
MemTable
Implements
Inherited Members
Extension Methods

Constructors

MemTable()

Constructor.

public MemTable()

MemTable(string)

Constructor.

public MemTable(string tableName)

Parameters

tableName string

MemTable(string, string)

Constructor.

public MemTable(string tableName, string tableNamespace)

Parameters

tableName string
tableNamespace string

Properties

AutoGenerateGuidKeys

When true it automatically generates Guid keys for the primary key column, when a new row is added

public bool AutoGenerateGuidKeys { get; set; }

Property Value

bool

CurrentRow

The current row

public DataRow CurrentRow { get; set; }

Property Value

DataRow

CurrentRowView

The current row view

public DataRowView CurrentRowView { get; set; }

Property Value

DataRowView

DataView

This is the view which is used in binding to simple controls and grids.

public DataView DataView { get; }

Property Value

DataView

DetailField

When this is a detail table, this is the field from this table which is mapped to the master field.

public string DetailField { get; set; }

Property Value

string

DetailFields

When this is a detail table, these fields from this table are mapped to master fields.

public string[] DetailFields { get; set; }

Property Value

string[]

DetailRowFilter

RowFilter for the master-detail relations

public string DetailRowFilter { get; set; }

Property Value

string

Details

The list of detail MemTable tables.

public DetailList Details { get; }

Property Value

DetailList

DetailsActive

Activates or deactivates the master detail relationships.

NOTE: It propagates the activation/de-activation down the tree.

public bool DetailsActive { get; set; }

Property Value

bool

EventsDisabled

Enables or disables the OnTableXXX, OnRowXXXX and OnColumnXXXX methods, to call or not the base version of the method.

public bool EventsDisabled { get; set; }

Property Value

bool

IsDetail

Returns true if this is a detail table.

public bool IsDetail { get; }

Property Value

bool

IsEmpty

True when this table has no rows at all.

public bool IsEmpty { get; }

Property Value

bool

KeyField

Primary key field

public string KeyField { get; set; }

Property Value

string

KeyFields

Primary key fields

public string[] KeyFields { get; set; }

Property Value

string[]

Level

Returns the "level" of this table. The level is the position of this table in a larger master-detail-subdetail tree which is automatically constructed.

public int Level { get; }

Property Value

int

Master

The master table when this is a detail

public MemTable Master { get; }

Property Value

MemTable

MasterField

When this is a detail table, this is the field from its master

public string MasterField { get; set; }

Property Value

string

MasterFields

When this is a detail table, these are the fields from its master

public string[] MasterFields { get; set; }

Property Value

string[]

RowProviders

The details as a list of IRowProvider

public ReadOnlyCollection<IRowProvider> RowProviders { get; }

Property Value

ReadOnlyCollection<IRowProvider>

Sqls

The Sql statements for the table

public TableSqls Sqls { get; }

Property Value

TableSqls

UserRowFilter

Filter set by user

public string UserRowFilter { get; set; }

Property Value

string

Methods

AcceptChangesAll()

Calls the AcceptChanges() to this table and its details.

public void AcceptChangesAll()

AddDetail(MemTable)

Adds a detail table to this table.

public void AddDetail(MemTable tblDetail)

Parameters

tblDetail MemTable

AddNewRow()

Adds and returns a new row. The new row is added to rows.

public DataRow AddNewRow()

Returns

DataRow

AddToDataSet(DataSet, DataTable)

Adds Table to the DS.Tables

public static void AddToDataSet(DataSet DS, DataTable Table)

Parameters

DS DataSet
Table DataTable

CheckTopTableErrors()

Throws an exception if this is a top table in a table tree, and possible errors exist.

public void CheckTopTableErrors()

ClearAll()

Clears this instance and all of its details of all the data.

WARNING: This does NOT set the Deleted flag in the RowState of the DataRows.

public void ClearAll()

CopyFrom(MemTable, bool)

Copies data from a source table.

public void CopyFrom(MemTable Source, bool IncludeDetails = true)

Parameters

Source MemTable
IncludeDetails bool

DeleteAll(bool)

Deletes all rows of this table and its details.

NOTE: This DOES set the Deleted flag in the RowState of the DataRows.

public void DeleteAll(bool AcceptChangesToo = true)

Parameters

AcceptChangesToo bool

FindRowProvider(string)

Returns the IRowProvider with the specified TableName, if found, else null.

public IRowProvider FindRowProvider(string TableName)

Parameters

TableName string

Returns

IRowProvider

GenId(bool)

Creates and returns a new Guid.

If UseBrackets is true, the new guid is surrounded by {}

public static string GenId(bool UseBrackets = false)

Parameters

UseBrackets bool

Returns

string

GetChildRows(DataRow)

Returns the child rows (belonging to this table) of a specified master row, belonging to the master table.

public DataRow[] GetChildRows(DataRow MasterRow)

Parameters

MasterRow DataRow

Returns

DataRow[]

GetColumns(string[])

Returns a list of columns.

public DataColumn[] GetColumns(string[] ColumnNames)

Parameters

ColumnNames string[]

Returns

DataColumn[]

GetDataRowView(DataRow, DataView)

Gets the DataRowView of a DataRow from a DataView.

public static DataRowView GetDataRowView(DataRow Row, DataView DataView)

Parameters

Row DataRow
DataView DataView

Returns

DataRowView

GetDetails()

Returns a list of all detail tables.

public MemTable[] GetDetails()

Returns

MemTable[]

GetRowProvider(string)

Returns the IRowProvider with the specified TableName, if found, else throws an exception.

public IRowProvider GetRowProvider(string TableName)

Parameters

TableName string

Returns

IRowProvider

GetTopTableErrors()

When this is a top table in a table tree, this method returns possible errors.

public string GetTopTableErrors()

Returns

string

GetTreeAsFlatList()

Returns this table and all of its detail tables as a flat list.

public List<MemTable> GetTreeAsFlatList()

Returns

List<MemTable>

HasChangesAll()

Returns true if this table, or any of its details, in any depth, has changes.

public bool HasChangesAll()

Returns

bool

InitializeAutoInc()

If Table has a single field as Key and that DataColumn is of type System.Int32, then initializes the properties of the DataColumn, so the column to be an autoincrement one (negative).

public void InitializeAutoInc()

MasterRowChanged()

Notification

public void MasterRowChanged()

NextTableName()

Constructs and returns a valid and unique TableName

public static string NextTableName()

Returns

string

OnColumnChanged(DataColumnChangeEventArgs)

Calls the base method, only if EventsDisabled is false, eventually deactivating the method.

protected override void OnColumnChanged(DataColumnChangeEventArgs e)

Parameters

e DataColumnChangeEventArgs

OnColumnChanging(DataColumnChangeEventArgs)

Calls the base method, only if EventsDisabled is false, eventually deactivating the method.

protected override void OnColumnChanging(DataColumnChangeEventArgs e)

Parameters

e DataColumnChangeEventArgs

OnRowChanged(DataRowChangeEventArgs)

Calls the base method, only if EventsDisabled is false, eventually deactivating the method.

protected override void OnRowChanged(DataRowChangeEventArgs e)

Parameters

e DataRowChangeEventArgs

OnRowChanging(DataRowChangeEventArgs)

Calls the base method, only if EventsDisabled is false, eventually deactivating the method.

protected override void OnRowChanging(DataRowChangeEventArgs e)

Parameters

e DataRowChangeEventArgs

OnRowDeleted(DataRowChangeEventArgs)

Calls the base method, only if EventsDisabled is false, eventually deactivating the method.

protected override void OnRowDeleted(DataRowChangeEventArgs e)

Parameters

e DataRowChangeEventArgs

OnRowDeleting(DataRowChangeEventArgs)

Calls the base method, only if EventsDisabled is false, eventually deactivating the method.

protected override void OnRowDeleting(DataRowChangeEventArgs e)

Parameters

e DataRowChangeEventArgs

OnTableCleared(DataTableClearEventArgs)

Calls the base method, only if EventsDisabled is false, eventually deactivating the method.

protected override void OnTableCleared(DataTableClearEventArgs e)

Parameters

e DataTableClearEventArgs

OnTableClearing(DataTableClearEventArgs)

Calls the base method, only if EventsDisabled is false, eventually deactivating the method.

protected override void OnTableClearing(DataTableClearEventArgs e)

Parameters

e DataTableClearEventArgs

OnTableNewRow(DataTableNewRowEventArgs)

Calls the base method, only if EventsDisabled is false, eventually deactivating the method.

protected override void OnTableNewRow(DataTableNewRowEventArgs e)

Parameters

e DataTableNewRowEventArgs

RefreshDetails()

Notification. Updates the current row and notifies all detail tables about the change.

public void RefreshDetails()

RejectChangesAll()

Calls the RejectChanges() to this table and its details.

public void RejectChangesAll()

RemoveDetail(MemTable)

Removes a detail table from this table.

public void RemoveDetail(MemTable tblDetail)

Parameters

tblDetail MemTable

RowProviderExists(string)

Returns true if a IRowProvider with the specified TableName exists.

public bool RowProviderExists(string TableName)

Parameters

TableName string

Returns

bool

SetAllRowsToNull(DataRow)

Sets all data rows to Value

public static void SetAllRowsToNull(DataRow Row)

Parameters

Row DataRow

SetCurrentRowToNull()

Sets the current row to null.

public void SetCurrentRowToNull()

UpdateCurrentRow()

Updates the current row.

public void UpdateCurrentRow()

ValidateRelationSchema()

Validates the relation schema.

Used when this is a detail table to check the validity of the relation to its master table.

public void ValidateRelationSchema()

Events

CurrentRowChanged

Occurs when the current row is changed.

public event EventHandler CurrentRowChanged

Event Type

EventHandler

MasterChanged

Occurs when the master is changed.

public event EventHandler MasterChanged

Event Type

EventHandler

MasterChanging

Occurs when the master is about to change

public event EventHandler MasterChanging

Event Type

EventHandler

NewRowAdded

Occurs when a new row is added.

public event EventHandler<DataTableNewRowEventArgs> NewRowAdded

Event Type

EventHandler<DataTableNewRowEventArgs>

NewRowAdding

Occurs when a new row is about to be added.

public event EventHandler<DataTableNewRowEventArgs> NewRowAdding

Event Type

EventHandler<DataTableNewRowEventArgs>