Class DatabaseObject
Class to represent a database through which the user can connect to and query from.
Inherited Members
Namespace: DatabaseConnector
Assembly: DatabaseConnector.dll
Syntax
public abstract class DatabaseObject
Constructors
| Improve this Doc View SourceDatabaseObject()
Initializes a new instance of the DatabaseObject class.
Declaration
public DatabaseObject()
DatabaseObject(ILogger)
Initializes a new instance of the DatabaseObject class.
Declaration
public DatabaseObject(ILogger logger)
Parameters
| Type | Name | Description |
|---|---|---|
| Microsoft.Extensions.Logging.ILogger | logger | The logger to be used in this library. |
DatabaseObject(String)
Initializes a new instance of the DatabaseObject class.
Declaration
public DatabaseObject(string connectionString)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | connectionString | The connection string to be used to connect to the database. |
DatabaseObject(String, ILogger)
Initializes a new instance of the DatabaseObject class.
Declaration
public DatabaseObject(string connectionString, ILogger logger)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | connectionString | The connection string to be used to connect to the database. |
| Microsoft.Extensions.Logging.ILogger | logger | The logger to be used in this library. |
Properties
| Improve this Doc View SourceConnected
Gets or sets a value indicating whether gets or sets the state of the database.
Declaration
protected bool Connected { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
ConnectionString
Gets or sets the connection string to connect to the database.
Declaration
protected string ConnectionString { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Logger
Gets or sets the logger to be used by the database.
Declaration
protected ILogger Logger { get; set; }
Property Value
| Type | Description |
|---|---|
| Microsoft.Extensions.Logging.ILogger |
Methods
| Improve this Doc View SourceConnect()
Connects to the database.
Declaration
public abstract bool Connect()
Returns
| Type | Description |
|---|---|
| System.Boolean | if the database has been successfully connected to.
|
Disconnect()
Disconnects from the database.
Declaration
public abstract bool Disconnect()
Returns
| Type | Description |
|---|---|
| System.Boolean | if the database has been successfully disconnected from.
|
ExecuteNonQuery(String)
Executes the given query that does not return any data (e.g. update, insert, delete).
Declaration
public abstract bool ExecuteNonQuery(string nonQuery)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | nonQuery | Query to execute. |
Returns
| Type | Description |
|---|---|
| System.Boolean | if query was successfully executed.
|
ExecuteQuery(String)
Executes the given query that retrieves data from the database.
Declaration
public abstract List<List<object>> ExecuteQuery(string query)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | query | Query to execute. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.List<System.Collections.Generic.List<System.Object>> | Data queried from the database. |
IsConnected()
Returns whether or not a connection has been established to the database.
if the database has been connected totrue
Declaration
public abstract bool IsConnected()
Returns
| Type | Description |
|---|---|
| System.Boolean | if the database has been connected to.
|