Class SqlCompactDbClient
Provides the database client class for SQL CE
Implements
Inherited Members
Namespace: TimeCockpit.Data.Database
Assembly: TimeCockpit.Data.dll
Syntax
public sealed class SqlCompactDbClient : DbClient, IDisposable
Properties
SkipBlobGarbageCollection
Gets a value indicating whether blob garbage collection should be skipped.
Declaration
protected override bool SkipBlobGarbageCollection { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Overrides
SupportsNoCheckConstraint
Gets a value indicating whether this db client supports disabling constraints.
Declaration
public override bool SupportsNoCheckConstraint { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Overrides
SupportsTableValuedParameters
Gets a value indicating whether this db client supports TVPs.
Declaration
public override bool SupportsTableValuedParameters { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Overrides
Methods
CreateDatabase(String, Guid)
Create a new database file.
Declaration
public static void CreateDatabase(string connectionString, Guid userAccountId)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | connectionString | Basic connection string to use. |
| System.Guid | userAccountId | User to create the database for. |
DeleteBlobGarbage(DbConnection, IEnumerable<BlobGarbageRow>)
Deletes rows from the blob garbage collection
Declaration
protected override void DeleteBlobGarbage(DbConnection conn, IEnumerable<BlobGarbageRow> blobGarbageCollection)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Data.Common.DbConnection | conn | Database connection used to access the database |
| System.Collections.Generic.IEnumerable<BlobGarbageRow> | blobGarbageCollection | Guids of the blob that should be deleted |
Overrides
ExecuteDatabaseOperation(Func<DbConnection, UInt64, DbCommand>, Boolean)
Executes a database operation.
Declaration
[CLSCompliant(false)]
protected override ulong ExecuteDatabaseOperation(Func<DbConnection, ulong, DbCommand> commandCreator, bool syncContent)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Func<System.Data.Common.DbConnection, System.UInt64, System.Data.Common.DbCommand> | commandCreator | Function that is used to create the database command object. |
| System.Boolean | syncContent | Indicates how and if the ModelElement that is targeted is synced. |
Returns
| Type | Description |
|---|---|
| System.UInt64 | Version of the database operation |
Overrides
FindOrCreateCommand(String, DbConnection)
Create DB command by looking it up in a cache of prepared commands or creating it.
Declaration
protected override DbCommand FindOrCreateCommand(string sqlText, DbConnection connection)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | sqlText | The SQL command text; always a SELECT statement. |
| System.Data.Common.DbConnection | connection | The database connection on which the command will be executed. |
Returns
| Type | Description |
|---|---|
| System.Data.Common.DbCommand | DB command from the cache or newly created command. |
Overrides
Remarks
Implementers who want to create a cache of prepared commands should look for a cached command
for sqlText. If the cache contains an appropriate command, a reference to this
command should be returned. If it doesn't, a new command should be created and returned.
After DbClient is done with the command, FinishCommand(DbCommand) will be called.
Use that method to clean up (e.g. dispose newly created command).
FindOrCreateCommand(String, DbConnection, Boolean)
Searches for a command with given SQL Text in a cache, or creates a new command if none is found.
Declaration
protected DbCommand FindOrCreateCommand(string sqlText, DbConnection connection, bool explicitPrepare = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | sqlText | The SQL Text. |
| System.Data.Common.DbConnection | connection | THe connection for creating new commands. |
| System.Boolean | explicitPrepare | True if the call is explicit (i.e. by PrepareQuery) or not. |
Returns
| Type | Description |
|---|---|
| System.Data.Common.DbCommand | Returns the command. |
FinishCommand(DbCommand)
Called after DbClient is done with the command.
Declaration
protected override void FinishCommand(DbCommand command)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Data.Common.DbCommand | command | A command previously returned by FindOrCreateCommand(String, DbConnection). |
Overrides
GetConnectionString(DbClientSettings)
Extracts the connection string from a set of settings.
Declaration
protected override string GetConnectionString(DbClientSettings settings)
Parameters
| Type | Name | Description |
|---|---|---|
| DbClientSettings | settings | Settings to extract from. |
Returns
| Type | Description |
|---|---|
| System.String | Final connection string. |
Overrides
GetDatabasePath()
Returns the absolute path of the folder containing the database file.
Declaration
public string GetDatabasePath()
Returns
| Type | Description |
|---|---|
| System.String | Path of the database file |
Remarks
The method uses the database's connection string to get the path of the database file. If the connection string is empty or malformed the method returns an empty string.
OpenConnectionAsync(CancellationToken)
Opens a new connection.
Declaration
protected override Task<DbConnection> OpenConnectionAsync(CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Data.Common.DbConnection> | Returns the newly opened connection. |