Interface ITableManager
- Namespace
- CMS.DataEngine
- Assembly
- CMS.DataEngine.dll
Ensures management of database table and table column.
public interface ITableManager
- Extension Methods
Properties
ConnectionString
Connection string name
string ConnectionString { get; set; }
Property Value
- string
DatabaseCulture
Database culture setting from the web.config.
string DatabaseCulture { get; }
Property Value
- string
DatabaseName
Gets database name.
string DatabaseName { get; }
Property Value
- string
DatabaseServerName
Gets database server name.
string DatabaseServerName { get; }
Property Value
- string
DatabaseServerVersion
Gets database server version.
string DatabaseServerVersion { get; }
Property Value
- string
DatabaseSize
Gets database size(including log size).
string DatabaseSize { get; }
Property Value
- string
DatabaseVersion
Gets database version
string DatabaseVersion { get; }
Property Value
- string
Methods
AddTableColumn(string, string, string, bool, string, bool)
Add column to specified table.
void AddTableColumn(string tableName, string columnName, string columnType, bool allowNull, string defaultValue, bool forceDefaultValue)
Parameters
tableNamestringTable name
columnNamestringName of a new column
columnTypestringType of a new column
allowNullboolAllow NULL values in new column or not
defaultValuestringDefault value of the column in system (en) culture. Null if no default value is set
forceDefaultValueboolIndicates if column default value should be set if column doesn't allow NULL values
AlterTableColumn(string, string, string, string, bool, string)
Rename, retype or allow/not allow NULL values in column
void AlterTableColumn(string tableName, string columnName, string newColumnName, string newColumnType, bool newColumnAllowNull, string newColumnDefaultValue)
Parameters
tableNamestringTable name
columnNamestringName of an old column
newColumnNamestringName of a new column
newColumnTypestringType of a new column
newColumnAllowNullboolAllow NULL values in new column or not
newColumnDefaultValuestringDefault value of a new column in system (en) culture
CreateColumnIndexes(string, string, DataSet)
Creates the table indexes.
void CreateColumnIndexes(string tableName, string columnName, DataSet ds)
Parameters
tableNamestringTable name
columnNamestringColumn name
dsDataSetDataSet with the indexes information
CreateForeignKey(string, string, string, string, string)
Creates a foreign key between the source table and the referenced table if a foreign key with the same name doesn't already exist.
void CreateForeignKey(string foreignKeyName, string sourceTableName, string sourceColumnName, string referencedTableName, string referencedColumn)
Parameters
foreignKeyNamestringForeign key name.
sourceTableNamestringSource table.
sourceColumnNamestringSource column name.
referencedTableNamestringReferenced table name.
referencedColumnstringReferenced column name.
CreateIndex(string, string, bool, IList<(string columnName, bool isAscendingOrder)>)
Creates a non-clustered index for a column(s) if an index with the same name doesn't already exist.
void CreateIndex(string indexName, string tableName, bool isUnique, IList<(string columnName, bool isAscendingOrder)> columns)
Parameters
indexNamestringIndex name.
tableNamestringTable name.
isUniqueboolIndicates whether index should be unique.
columnsIList<(string columnName, bool isAscendingOrder)>Collection of index columns with order specification.
CreateTable(string, string)
Creates specified table in database.
void CreateTable(string tableName, string primaryKeyName)
Parameters
tableNamestringTable name to create
primaryKeyNamestringPrimary key of table to create
CreateTable(string, string, bool)
Creates specified table in database with specified primary key column with or without identity.
void CreateTable(string tableName, string primaryKeyName, bool setIdentity)
Parameters
tableNamestringTable name to create
primaryKeyNamestringPrimary key of table to create
setIdentityboolIf true, sets identity on primary key column
CreateView(string, string, bool, string)
Creates specified view in database for given data class.
void CreateView(string viewName, string selectExpression, bool indexed, string schema)
Parameters
viewNamestringView name to create
selectExpressionstringSelect expression for the view
indexedboolIf true, the view is indexed (schema bound)
schemastringDatabase schema
DropTable(string)
Drop specified table from database.
void DropTable(string tableName)
Parameters
tableNamestringTable name to drop
DropTableColumn(string, string)
Remove column from specified table.
void DropTableColumn(string tableName, string columnName)
Parameters
tableNamestringTable name
columnNamestringName of column to remove
DropView(string)
Drop specified view from database.
string DropView(string viewName)
Parameters
viewNamestringView name to drop
Returns
- string
ExecuteQuery(string, QueryDataParameters, QueryTypeEnum)
Executes query and returns the results in a DataSet.
DataSet ExecuteQuery(string queryText, QueryDataParameters queryParams, QueryTypeEnum queryType)
Parameters
queryTextstringQuery text
queryParamsQueryDataParametersQuery parameters
queryTypeQueryTypeEnumQuery type
Returns
- DataSet
GetColumnInformation(string, string)
Returns DataSet with specfied table column information retrieved from database information schema. Returns columns ColumnName, DataType, DataSize, DataPrecision, Nullable, DefaultValue
DataSet GetColumnInformation(string tableName, string columnName)
Parameters
tableNamestringDatabase table name
columnNamestringDatabase table column name
Returns
- DataSet
GetPrimaryKeyColumns(string)
Returns list of column names which represent primary keys of the specified database table. Returns empty list if primary keys are not found.
List<string> GetPrimaryKeyColumns(string tableName)
Parameters
tableNamestringDatabase table name
Returns
- List<string>
GetTablePKName(string)
Returns name of the primary key. If more columns in PK, names are separated by semicolon ";".
string GetTablePKName(string tableName)
Parameters
tableNamestringName of the table to get PK column(s) from.
Returns
- string
GetValueString(object)
Returns the value string using the database culture.
string GetValueString(object value)
Parameters
valueobjectValue to convert
Returns
- string
GetXmlSchema(string)
Returns XML schema for specified table.
string GetXmlSchema(string tableName)
Parameters
tableNamestringName of a table to get xml schema for
Returns
- string
RecreatePKConstraint(string, string[])
Drops the current PK constraint and creates new from given columns.
void RecreatePKConstraint(string tableName, string[] primaryKeyColumns)
Parameters
tableNamestringName of the table
primaryKeyColumnsstring[]List of columns which should be part of primary key
RefreshView(string)
Refreshes specified view in database.
void RefreshView(string viewName)
Parameters
viewNamestringView name to refresh
RenameTable(string, string)
Changes name of the table with original name according to the new name.
void RenameTable(string oldTableName, string newTableName)
Parameters
oldTableNamestringName of the table to rename
newTableNamestringNew name of the table
TableExists(string)
Determines whether specified DB table exists or not.
bool TableExists(string tableName)
Parameters
tableNamestringTable name to check
Returns
- bool