Class MemTable
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
tableNamestring
MemTable(string, string)
Constructor.
public MemTable(string tableName, string tableNamespace)
Parameters
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
CurrentRow
The current row
public DataRow CurrentRow { get; set; }
Property Value
CurrentRowView
The current row view
public DataRowView CurrentRowView { get; set; }
Property Value
DataView
This is the view which is used in binding to simple controls and grids.
public DataView DataView { get; }
Property Value
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
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
Details
The list of detail MemTable tables.
public DetailList Details { get; }
Property Value
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
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
IsDetail
Returns true if this is a detail table.
public bool IsDetail { get; }
Property Value
IsEmpty
True when this table has no rows at all.
public bool IsEmpty { get; }
Property Value
KeyField
Primary key field
public string KeyField { get; set; }
Property Value
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
Master
The master table when this is a detail
public MemTable Master { get; }
Property Value
MasterField
When this is a detail table, this is the field from its master
public string MasterField { get; set; }
Property Value
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
Sqls
The Sql statements for the table
public TableSqls Sqls { get; }
Property Value
UserRowFilter
Filter set by user
public string UserRowFilter { get; set; }
Property Value
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
tblDetailMemTable
AddNewRow()
Adds and returns a new row. The new row is added to rows.
public DataRow AddNewRow()
Returns
AddToDataSet(DataSet, DataTable)
Adds Table to the DS.Tables
public static void AddToDataSet(DataSet DS, DataTable Table)
Parameters
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
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
AcceptChangesToobool
FindRowProvider(string)
Returns the IRowProvider with the specified TableName, if found, else null.
public IRowProvider FindRowProvider(string TableName)
Parameters
TableNamestring
Returns
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
UseBracketsbool
Returns
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
MasterRowDataRow
Returns
- DataRow[]
GetColumns(string[])
Returns a list of columns.
public DataColumn[] GetColumns(string[] ColumnNames)
Parameters
ColumnNamesstring[]
Returns
GetDataRowView(DataRow, DataView)
Gets the DataRowView of a DataRow from a DataView.
public static DataRowView GetDataRowView(DataRow Row, DataView DataView)
Parameters
Returns
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
TableNamestring
Returns
GetTopTableErrors()
When this is a top table in a table tree, this method returns possible errors.
public string GetTopTableErrors()
Returns
GetTreeAsFlatList()
Returns this table and all of its detail tables as a flat list.
public List<MemTable> GetTreeAsFlatList()
Returns
HasChangesAll()
Returns true if this table, or any of its details, in any depth, has changes.
public bool HasChangesAll()
Returns
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
OnColumnChanged(DataColumnChangeEventArgs)
Calls the base method, only if EventsDisabled is false, eventually deactivating the method.
protected override void OnColumnChanged(DataColumnChangeEventArgs e)
Parameters
OnColumnChanging(DataColumnChangeEventArgs)
Calls the base method, only if EventsDisabled is false, eventually deactivating the method.
protected override void OnColumnChanging(DataColumnChangeEventArgs e)
Parameters
OnRowChanged(DataRowChangeEventArgs)
Calls the base method, only if EventsDisabled is false, eventually deactivating the method.
protected override void OnRowChanged(DataRowChangeEventArgs e)
Parameters
OnRowChanging(DataRowChangeEventArgs)
Calls the base method, only if EventsDisabled is false, eventually deactivating the method.
protected override void OnRowChanging(DataRowChangeEventArgs e)
Parameters
OnRowDeleted(DataRowChangeEventArgs)
Calls the base method, only if EventsDisabled is false, eventually deactivating the method.
protected override void OnRowDeleted(DataRowChangeEventArgs e)
Parameters
OnRowDeleting(DataRowChangeEventArgs)
Calls the base method, only if EventsDisabled is false, eventually deactivating the method.
protected override void OnRowDeleting(DataRowChangeEventArgs e)
Parameters
OnTableCleared(DataTableClearEventArgs)
Calls the base method, only if EventsDisabled is false, eventually deactivating the method.
protected override void OnTableCleared(DataTableClearEventArgs e)
Parameters
OnTableClearing(DataTableClearEventArgs)
Calls the base method, only if EventsDisabled is false, eventually deactivating the method.
protected override void OnTableClearing(DataTableClearEventArgs e)
Parameters
OnTableNewRow(DataTableNewRowEventArgs)
Calls the base method, only if EventsDisabled is false, eventually deactivating the method.
protected override void OnTableNewRow(DataTableNewRowEventArgs e)
Parameters
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
tblDetailMemTable
RowProviderExists(string)
Returns true if a IRowProvider with the specified TableName exists.
public bool RowProviderExists(string TableName)
Parameters
TableNamestring
Returns
SetAllRowsToNull(DataRow)
Sets all data rows to Value
public static void SetAllRowsToNull(DataRow Row)
Parameters
RowDataRow
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
MasterChanged
Occurs when the master is changed.
public event EventHandler MasterChanged
Event Type
MasterChanging
Occurs when the master is about to change
public event EventHandler MasterChanging
Event Type
NewRowAdded
Occurs when a new row is added.
public event EventHandler<DataTableNewRowEventArgs> NewRowAdded
Event Type
NewRowAdding
Occurs when a new row is about to be added.
public event EventHandler<DataTableNewRowEventArgs> NewRowAdding