Class CPDbBaseClass
- Namespace
- Contensive.BaseClasses
- Assembly
- CPBase.dll
CP.Db - This object references the database directly
public abstract class CPDbBaseClass : IDisposable
- Inheritance
-
CPDbBaseClass
- Implements
- Inherited Members
Properties
SQLTimeout
get or set the timeout in seconds for all Db methods in the current process
public abstract int SQLTimeout { get; set; }
Property Value
Methods
Add(string, int)
Add a record to a table in the default datasource and return its Id
public abstract int Add(string tableName, int createdByUserId)
Parameters
Returns
CreateFieldPathFilename(string, string, int, FieldTypeIdEnum)
creates a pathFilename for a field that stores text content, like css, js, etc.
public abstract string CreateFieldPathFilename(string tableName, string fieldName, int recordId, CPContentBaseClass.FieldTypeIdEnum fieldTypeId)
Parameters
tableNamestringfieldNamestringrecordIdintfieldTypeIdCPContentBaseClass.FieldTypeIdEnum
Returns
CreateFieldPathFilename(string, string, int, fileTypeIdEnum)
Deprecated
[Obsolete("Deprecated. Use CreateUploadFieldPathFilename with no fieldType or FileType", false)]
public abstract string CreateFieldPathFilename(string tableName, string fieldName, int recordId, CPContentBaseClass.fileTypeIdEnum fieldType)
Parameters
tableNamestringfieldNamestringrecordIdintfieldTypeCPContentBaseClass.fileTypeIdEnum
Returns
CreateUploadFieldPath(string, string, int)
creates a path for a field that holds the path and filename of an uploaded file (Only type=file and type=image)
public abstract string CreateUploadFieldPath(string tableName, string fieldName, int recordId)
Parameters
Returns
CreateUploadFieldPathFilename(string, string, int, string)
creates the pathFilename for a field that holds the path and filename of an uploaded file (Only type=file and type=image)
public abstract string CreateUploadFieldPathFilename(string tableName, string fieldName, int recordId, string filename)
Parameters
Returns
CreateUploadFieldPathFilename(string, string, int, string, FieldTypeIdEnum)
Deprecated
[Obsolete("Deprecated. Use CreateUploadFieldPathFilename with no fieldType or FileType", false)]
public abstract string CreateUploadFieldPathFilename(string tableName, string fieldName, int recordId, string filename, CPContentBaseClass.FieldTypeIdEnum fieldTypeId)
Parameters
tableNamestringfieldNamestringrecordIdintfilenamestringfieldTypeIdCPContentBaseClass.FieldTypeIdEnum
Returns
CreateUploadFieldPathFilename(string, string, int, string, fileTypeIdEnum)
Deprecated
[Obsolete("Deprecated. Use CreateUploadFieldPathFilename with no fieldType or FileType", false)]
public abstract string CreateUploadFieldPathFilename(string tableName, string fieldName, int recordId, string filename, CPContentBaseClass.fileTypeIdEnum fileType)
Parameters
tableNamestringfieldNamestringrecordIdintfilenamestringfileTypeCPContentBaseClass.fileTypeIdEnum
Returns
DbGetConnectionString(string)
Deprecated
[Obsolete("Use GetConnectionString( dataSourceName )")]
public abstract string DbGetConnectionString(string DataSourcename)
Parameters
DataSourcenamestring
Returns
DbGetDataSourceType(string)
Deprecated
[Obsolete("Use GetDataSourceType( dataSourceName )")]
public abstract int DbGetDataSourceType(string DataSourcename)
Parameters
DataSourcenamestring
Returns
DbGetTableID(string)
Deprecated
[Obsolete("Use GetTableId instead.", false)]
public abstract int DbGetTableID(string TableName)
Parameters
TableNamestring
Returns
DbIsTable(string, string)
Deprecated
[Obsolete("Use isTable instead", false)]
public abstract bool DbIsTable(string DataSourcename, string TableName)
Parameters
Returns
DbIsTableField(string, string, string)
Deprecated
[Obsolete("Use isTableField instead", false)]
public abstract bool DbIsTableField(string DataSourcename, string TableName, string FieldName)
Parameters
Returns
Delete(string, int)
Delete the record specified by tablename and recordId
public abstract void Delete(string tableName, int recordId)
Parameters
Delete(string, string)
Delete the record specified by tablename and guid
public abstract void Delete(string tableName, string guid)
Parameters
Delete(string, string, int)
Deprecated
[Obsolete("Deprecated. Use methods without datasource reference. Instead create non-default datasource with CP.DbNew(datasourcename).", false)]
public abstract void Delete(string dataSourcename, string tableName, int recordId)
Parameters
DeleteRows(string, string)
Delete the record specified by tablename and guid
public abstract void DeleteRows(string tableName, string sqlCriteria)
Parameters
Dispose()
Support disposable for non-default datasources
public abstract void Dispose()
EncodeSQLBoolean(bool)
Encode a boolean value to be used in an sql Query for this application. Boolean fields are stored as integers in Contensive. Example 'select id from ccmembers where active='+EncodeSqlBoolean(true)
public abstract string EncodeSQLBoolean(bool sourceBoolean)
Parameters
sourceBooleanbool
Returns
EncodeSQLDate(DateTime)
Encode a date value to be used in an sql Query for this application. Example 'select id from ccmembers where dateadded>'+EncodeSqlDate( myBirthday )
public abstract string EncodeSQLDate(DateTime sourceDate)
Parameters
sourceDateDateTime
Returns
EncodeSQLNumber(double)
Encode a numeric value (integer or double) to be used in an sql Query for this application. Example 'select id from orders where totalAmount>'+EncodeSqlNumber( 1000.00 )
public abstract string EncodeSQLNumber(double sourceNumber)
Parameters
sourceNumberdouble
Returns
EncodeSQLNumber(int)
Encode a numeric value (integer or double) to be used in an sql Query for this application. Example 'select id where id>'+EncodeSqlNumber( 1000 )
public abstract string EncodeSQLNumber(int sourceNumber)
Parameters
sourceNumberint
Returns
EncodeSQLText(string)
Encode a text string value to be used in an sql Query for this application. Example 'select id where name='+EncodeSqlText( 'bob' )
public abstract string EncodeSQLText(string sourceText)
Parameters
sourceTextstring
Returns
EncodeSQLTextLike(string)
Encode a text string value to be used in an sql Query for this application. Example 'select id where name like '+EncodeSqlText( 'bob' )
public abstract string EncodeSQLTextLike(string sourceText)
Parameters
sourceTextstring
Returns
ExecuteNonQuery(string)
Execute an sql command on a specific datasource. No data is returned.
public abstract void ExecuteNonQuery(string sql)
Parameters
sqlstring
ExecuteNonQuery(string, ref int)
Execute an sql command on a specific datasource. No data is returned.
public abstract void ExecuteNonQuery(string sql, ref int recordsAffected)
Parameters
ExecuteNonQuery(string, string)
Deprecated
[Obsolete("Deprecated. Use methods without datasource.", false)]
public abstract void ExecuteNonQuery(string sql, string dataSourceName)
Parameters
ExecuteNonQuery(string, string, ref int)
Deprecated
[Obsolete("Deprecated. Use methods without datasource.", false)]
public abstract void ExecuteNonQuery(string sql, string dataSourceName, ref int recordsAffected)
Parameters
ExecuteNonQueryAsync(string)
Execute an sql command on a specific datasource, dotnet async task pattern.
public abstract Task<int> ExecuteNonQueryAsync(string sql)
Parameters
sqlstring
Returns
ExecuteNonQueryAsync(string, string)
Deprecated
[Obsolete("Deprecated. Use methods without datasource.", false)]
public abstract void ExecuteNonQueryAsync(string sql, string dataSourceName)
Parameters
ExecuteQuery(string)
Execute an sql query and return a datatable. Start at record 0, max records returned is 10M.
public abstract DataTable ExecuteQuery(string sql)
Parameters
sqlstring
Returns
ExecuteQuery(string, int)
Execute an sql query and return a datatable. Max records returned is 10M.
public abstract DataTable ExecuteQuery(string sql, int startRecord)
Parameters
Returns
ExecuteQuery(string, int, int)
Execute a query and return a datatable.
public abstract DataTable ExecuteQuery(string sql, int startRecord, int maxRecords)
Parameters
Returns
ExecuteQuery(string, string)
Deprecated
[Obsolete("Deprecated. Use methods without datasource.", false)]
public abstract DataTable ExecuteQuery(string sql, string dataSourceName)
Parameters
Returns
ExecuteQuery(string, string, int)
Deprecated
[Obsolete("Deprecated. Use methods without datasource.", false)]
public abstract DataTable ExecuteQuery(string sql, string dataSourceName, int startRecord)
Parameters
Returns
ExecuteQuery(string, string, int, int)
Deprecated
[Obsolete("Deprecated. Use methods without datasource.", false)]
public abstract DataTable ExecuteQuery(string sql, string dataSourceName, int startRecord, int maxRecords)
Parameters
Returns
ExecuteRemoteQuery(string)
Execute a sql query stored with getRemoteQueryKey.
public abstract DataTable ExecuteRemoteQuery(string remoteQueryKey)
Parameters
remoteQueryKeystring
Returns
ExecuteSQL(string)
Deprecated
[Obsolete("Convert to datatables and use executeQuery(), executeNonQuery(), or executeNonQueryAsync()", false)]
public abstract object ExecuteSQL(string SQL)
Parameters
SQLstring
Returns
ExecuteSQL(string, string)
Deprecated
[Obsolete("Convert to datatables and use executeQuery(), executeNonQuery(), or executeNonQueryAsync()", false)]
public abstract object ExecuteSQL(string SQL, string DataSourcename)
Parameters
Returns
ExecuteSQL(string, string, string)
Deprecated
[Obsolete("Convert to datatables and use executeQuery(), executeNonQuery(), or executeNonQueryAsync()", false)]
public abstract object ExecuteSQL(string SQL, string DataSourcename, string Retries)
Parameters
Returns
ExecuteSQL(string, string, string, string)
Deprecated
[Obsolete("Convert to datatables and use executeQuery(), executeNonQuery(), or executeNonQueryAsync()", false)]
public abstract object ExecuteSQL(string SQL, string DataSourcename, string Retries, string PageSize)
Parameters
Returns
ExecuteSQL(string, string, string, string, string)
Deprecated
[Obsolete("Convert to datatables and use executeQuery(), executeNonQuery(), or executeNonQueryAsync()", false)]
public abstract object ExecuteSQL(string SQL, string DataSourcename, string Retries, string PageSize, string PageNumber)
Parameters
Returns
ExecuteScalar(string)
Execute an sql query and return an integer. query should return a single value.
public abstract int ExecuteScalar(string sql)
Parameters
sqlstring
Returns
GetConnectionString()
get the connection string for the default device
public abstract string GetConnectionString()
Returns
GetConnectionString(string)
Deprecated
[Obsolete("Deprecated. Use methods without datasource.", false)]
public abstract string GetConnectionString(string dataSourcename)
Parameters
dataSourcenamestring
Returns
GetDataSourceType(string)
Deprecated
[Obsolete("Only Sql Server currently supported", false)]
public abstract int GetDataSourceType(string DataSourcename)
Parameters
DataSourcenamestring
Returns
GetRemoteQueryKey(string)
To give a remote method the ability to run an arbitrary query, store it as a remote query and executeRemoteQuery()
public abstract string GetRemoteQueryKey(string sql)
Parameters
sqlstring
Returns
GetRemoteQueryKey(string, int)
To give a remote method the ability to run an arbitrary query, store it as a remote query and executeRemoteQuery()
public abstract string GetRemoteQueryKey(string sql, int pageSize)
Parameters
Returns
GetRemoteQueryKey(string, string)
Deprecated
[Obsolete("Deprecated. Use methods without datasource.", false)]
public abstract string GetRemoteQueryKey(string sql, string DataSourceName)
Parameters
Returns
GetRemoteQueryKey(string, string, int)
Deprecated
[Obsolete("Deprecated. Use methods without datasource.", false)]
public abstract string GetRemoteQueryKey(string sql, string DataSourceName, int pageSize)
Parameters
Returns
GetTableID(string)
Deprecated
[Obsolete("Deprecated. Use CP.Content.GetTableId().", false)]
public abstract int GetTableID(string tableName)
Parameters
tableNamestring
Returns
Insert(string, NameValueCollection, int)
Add a record to a table and return the record in a datatable
public abstract DataTable Insert(string tableName, NameValueCollection sqlList, int createdByUserId)
Parameters
tableNamestringThe table to be inserted.
sqlListNameValueCollectionNameValue pairs to be inserted. Name is the field name. Value is saved to the field, formatted for an sql statement according to the correct type. ex sqlList.Add("name", cp.db.EncodeSqlText("Bob Smith"))
createdByUserIdintThe user id to be set in the created-by and modified-by fields
Returns
Insert(string, int)
Add a record to a table and return the record in a datatable
public abstract DataTable Insert(string tableName, int createdByUserId)
Parameters
Returns
IsTable(string)
Return true if this is a valid database table in the current application
public abstract bool IsTable(string tableName)
Parameters
tableNamestring
Returns
IsTable(string, string)
Deprecated
[Obsolete("Deprecated. Use methods without datasource.", false)]
public abstract bool IsTable(string dataSourcename, string tableName)
Parameters
Returns
IsTableField(string, string)
Return true if this is a valid database field in a valid table in the current application
public abstract bool IsTableField(string tableName, string fieldName)
Parameters
Returns
IsTableField(string, string, string)
Deprecated
[Obsolete("Deprecated. Use methods without datasource.", false)]
public abstract bool IsTableField(string dataSourcename, string tableName, string fieldName)
Parameters
Returns
Update(string, string, NameValueCollection)
update records in a table. Criteria is an sql compatible where-clause, the sqlList is a list of fields and values to update
public abstract void Update(string tableName, string criteria, NameValueCollection sqlList)
Parameters
tableNamestringThe table to be updated.
criteriastringSql compatible where clause to select the record(s) that will be updated.
sqlListNameValueCollectionNameValue pairs. Name is the field name. Value is saved to the field, formatted for an sql statement according to the correct type. ex sqlList.Add("name", cp.db.EncodeSqlText("Bob Smith"))
Update(string, string, NameValueCollection, bool)
update records in a table. Criteria is an sql compatible where-clause, the sqlList is a list of fields and values to update. If Async is true, the query is queued for later
public abstract void Update(string tableName, string criteria, NameValueCollection sqlList, bool Async)
Parameters
tableNamestringcriteriastringsqlListNameValueCollectionAsyncbool