SQL - Extended  1.0.0
Pi-Con: Small utilities makes the difference
Public Member Functions | Static Public Member Functions | Public Attributes | Properties | List of all members
SQLite.SQLiteAsyncConnection Class Reference

A pooled asynchronous connection to a SQLite database. More...

Public Member Functions

 SQLiteAsyncConnection (string databasePath, bool storeDateTimeAsTicks=true)
 Constructs a new SQLiteAsyncConnection and opens a pooled SQLite database specified by databasePath. More...
 
 SQLiteAsyncConnection (string databasePath, SQLiteOpenFlags openFlags, bool storeDateTimeAsTicks=true)
 Constructs a new SQLiteAsyncConnection and opens a pooled SQLite database specified by databasePath. More...
 
 SQLiteAsyncConnection (SQLiteConnectionString connectionString)
 Constructs a new SQLiteAsyncConnection and opens a pooled SQLite database using the given connection string. More...
 
TimeSpan GetBusyTimeout ()
 The amount of time to wait for a table to become unlocked. More...
 
Task SetBusyTimeoutAsync (TimeSpan value)
 Sets the amount of time to wait for a table to become unlocked. More...
 
Task EnableWriteAheadLoggingAsync ()
 Enables the write ahead logging. WAL is significantly faster in most scenarios by providing better concurrency and better disk IO performance than the normal journal mode. You only need to call this function once in the lifetime of the database. More...
 
SQLiteConnectionWithLock GetConnection ()
 Gets the pooled lockable connection used by this async connection. You should never need to use this. This is provided only to add additional functionality to SQLite-net. If you use this connection, you must use the Lock method on it while using it. More...
 
Task CloseAsync ()
 Closes any pooled connections used by the database. More...
 
Task EnableLoadExtensionAsync (bool enabled)
 Enable or disable extension loading. More...
 
Task< CreateTableResultCreateTableAsync< T > (CreateFlags createFlags=CreateFlags.None)
 Executes a "create table if not exists" on the database. It also creates any specified indexes on the columns of the table. It uses a schema automatically generated from the specified type. You can later access this schema by calling GetMapping. More...
 
Task< CreateTableResultCreateTableAsync (Type ty, CreateFlags createFlags=CreateFlags.None)
 Executes a "create table if not exists" on the database. It also creates any specified indexes on the columns of the table. It uses a schema automatically generated from the specified type. You can later access this schema by calling GetMapping. More...
 
Task< CreateTablesResultCreateTablesAsync< T, T2 > (CreateFlags createFlags=CreateFlags.None)
 Executes a "create table if not exists" on the database for each type. It also creates any specified indexes on the columns of the table. It uses a schema automatically generated from the specified type. You can later access this schema by calling GetMapping. More...
 
Task< CreateTablesResultCreateTablesAsync< T, T2, T3 > (CreateFlags createFlags=CreateFlags.None)
 Executes a "create table if not exists" on the database for each type. It also creates any specified indexes on the columns of the table. It uses a schema automatically generated from the specified type. You can later access this schema by calling GetMapping. More...
 
Task< CreateTablesResultCreateTablesAsync< T, T2, T3, T4 > (CreateFlags createFlags=CreateFlags.None)
 Executes a "create table if not exists" on the database for each type. It also creates any specified indexes on the columns of the table. It uses a schema automatically generated from the specified type. You can later access this schema by calling GetMapping. More...
 
Task< CreateTablesResultCreateTablesAsync< T, T2, T3, T4, T5 > (CreateFlags createFlags=CreateFlags.None)
 Executes a "create table if not exists" on the database for each type. It also creates any specified indexes on the columns of the table. It uses a schema automatically generated from the specified type. You can later access this schema by calling GetMapping. More...
 
Task< CreateTablesResultCreateTablesAsync (CreateFlags createFlags=CreateFlags.None, params Type[] types)
 Executes a "create table if not exists" on the database for each type. It also creates any specified indexes on the columns of the table. It uses a schema automatically generated from the specified type. You can later access this schema by calling GetMapping. More...
 
Task< int > DropTableAsync< T > ()
 Executes a "drop table" on the database. This is non-recoverable. More...
 
Task< int > DropTableAsync (TableMapping map)
 Executes a "drop table" on the database. This is non-recoverable. More...
 
Task< int > CreateIndexAsync (string tableName, string columnName, bool unique=false)
 Creates an index for the specified table and column. More...
 
Task< int > CreateIndexAsync (string indexName, string tableName, string columnName, bool unique=false)
 Creates an index for the specified table and column. More...
 
Task< int > CreateIndexAsync (string tableName, string[] columnNames, bool unique=false)
 Creates an index for the specified table and columns. More...
 
Task< int > CreateIndexAsync (string indexName, string tableName, string[] columnNames, bool unique=false)
 Creates an index for the specified table and columns. More...
 
Task< int > CreateIndexAsync< T > (Expression< Func< T, object >> property, bool unique=false)
 Creates an index for the specified object property. e.g. CreateIndex<Client>(c => c.Name); More...
 
Task< int > InsertAsync (object obj)
 Inserts the given object and retrieves its auto incremented primary key if it has one. More...
 
Task< int > InsertAsync (object obj, Type objType)
 Inserts the given object (and updates its auto incremented primary key if it has one). The return value is the number of rows added to the table. More...
 
Task< int > InsertAsync (object obj, string extra)
 Inserts the given object (and updates its auto incremented primary key if it has one). The return value is the number of rows added to the table. More...
 
Task< int > InsertAsync (object obj, string extra, Type objType)
 Inserts the given object (and updates its auto incremented primary key if it has one). The return value is the number of rows added to the table. More...
 
Task< int > InsertOrReplaceAsync (object obj)
 Inserts the given object (and updates its auto incremented primary key if it has one). The return value is the number of rows added to the table. If a UNIQUE constraint violation occurs with some pre-existing object, this function deletes the old object. More...
 
Task< int > InsertOrReplaceAsync (object obj, Type objType)
 Inserts the given object (and updates its auto incremented primary key if it has one). The return value is the number of rows added to the table. If a UNIQUE constraint violation occurs with some pre-existing object, this function deletes the old object. More...
 
Task< int > UpdateAsync (object obj)
 Updates all of the columns of a table using the specified object except for its primary key. The object is required to have a primary key. More...
 
Task< int > UpdateAsync (object obj, Type objType)
 Updates all of the columns of a table using the specified object except for its primary key. The object is required to have a primary key. More...
 
Task< int > UpdateAllAsync (IEnumerable objects, bool runInTransaction=true)
 Updates all specified objects. More...
 
Task< int > DeleteAsync (object objectToDelete)
 Deletes the given object from the database using its primary key. More...
 
Task< int > DeleteAsync< T > (object primaryKey)
 Deletes the object with the specified primary key. More...
 
Task< int > DeleteAsync (object primaryKey, TableMapping map)
 Deletes the object with the specified primary key. More...
 
Task< int > DeleteAllAsync< T > ()
 Deletes all the objects from the specified table. WARNING WARNING: Let me repeat. It deletes ALL the objects from the specified table. Do you really want to do that? More...
 
Task< int > DeleteAllAsync (TableMapping map)
 Deletes all the objects from the specified table. WARNING WARNING: Let me repeat. It deletes ALL the objects from the specified table. Do you really want to do that? More...
 
Task BackupAsync (string destinationDatabasePath, string databaseName="main")
 Backup the entire database to the specified path. More...
 
Task< T > GetAsync< T > (object pk)
 Attempts to retrieve an object with the given primary key from the table associated with the specified type. Use of this method requires that the given type have a designated PrimaryKey (using the PrimaryKeyAttribute). More...
 
Task< object > GetAsync (object pk, TableMapping map)
 Attempts to retrieve an object with the given primary key from the table associated with the specified type. Use of this method requires that the given type have a designated PrimaryKey (using the PrimaryKeyAttribute). More...
 
Task< T > GetAsync< T > (Expression< Func< T, bool >> predicate)
 Attempts to retrieve the first object that matches the predicate from the table associated with the specified type. More...
 
Task< T > FindAsync< T > (object pk)
 Attempts to retrieve an object with the given primary key from the table associated with the specified type. Use of this method requires that the given type have a designated PrimaryKey (using the PrimaryKeyAttribute). More...
 
Task< object > FindAsync (object pk, TableMapping map)
 Attempts to retrieve an object with the given primary key from the table associated with the specified type. Use of this method requires that the given type have a designated PrimaryKey (using the PrimaryKeyAttribute). More...
 
Task< T > FindAsync< T > (Expression< Func< T, bool >> predicate)
 Attempts to retrieve the first object that matches the predicate from the table associated with the specified type. More...
 
Task< T > FindWithQueryAsync< T > (string query, params object[] args)
 Attempts to retrieve the first object that matches the query from the table associated with the specified type. More...
 
Task< object > FindWithQueryAsync (TableMapping map, string query, params object[] args)
 Attempts to retrieve the first object that matches the query from the table associated with the specified type. More...
 
Task< TableMappingGetMappingAsync (Type type, CreateFlags createFlags=CreateFlags.None)
 Retrieves the mapping that is automatically generated for the given type. More...
 
Task< TableMappingGetMappingAsync< T > (CreateFlags createFlags=CreateFlags.None)
 Retrieves the mapping that is automatically generated for the given type. More...
 
Task< List< SQLiteConnection.ColumnInfo > > GetTableInfoAsync (string tableName)
 Query the built-in sqlite table_info table for a specific tables columns. More...
 
Task< int > ExecuteAsync (string query, params object[] args)
 Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?' in the command text for each of the arguments and then executes that command. Use this method instead of Query when you don't expect rows back. Such cases include INSERTs, UPDATEs, and DELETEs. You can set the Trace or TimeExecution properties of the connection to profile execution. More...
 
Task< int > InsertAllAsync (IEnumerable objects, bool runInTransaction=true)
 Inserts all specified objects. More...
 
Task< int > InsertAllAsync (IEnumerable objects, string extra, bool runInTransaction=true)
 Inserts all specified objects. More...
 
Task< int > InsertAllAsync (IEnumerable objects, Type objType, bool runInTransaction=true)
 Inserts all specified objects. More...
 
Task RunInTransactionAsync (Action< SQLiteConnection > action)
 Executes action within a (possibly nested) transaction by wrapping it in a SAVEPOINT. If an exception occurs the whole transaction is rolled back, not just the current savepoint. The exception is rethrown. More...
 
AsyncTableQuery< T > Table< T > ()
 Returns a queryable interface to the table represented by the given type. More...
 
Task< T > ExecuteScalarAsync< T > (string query, params object[] args)
 Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?' in the command text for each of the arguments and then executes that command. Use this method when return primitive values. You can set the Trace or TimeExecution properties of the connection to profile execution. More...
 
Task< List< T > > QueryAsync< T > (string query, params object[] args)
 Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?' in the command text for each of the arguments and then executes that command. It returns each row of the result using the mapping automatically generated for the given type. More...
 
Task< List< T > > QueryScalarsAsync< T > (string query, params object[] args)
 Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?' in the command text for each of the arguments and then executes that command. It returns the first column of each row of the result. More...
 
Task< List< object > > QueryAsync (TableMapping map, string query, params object[] args)
 Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?' in the command text for each of the arguments and then executes that command. It returns each row of the result using the specified mapping. This function is only used by libraries in order to query the database via introspection. It is normally not used. More...
 
Task< IEnumerable< T > > DeferredQueryAsync< T > (string query, params object[] args)
 Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?' in the command text for each of the arguments and then executes that command. It returns each row of the result using the mapping automatically generated for the given type. More...
 
Task< IEnumerable< object > > DeferredQueryAsync (TableMapping map, string query, params object[] args)
 Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?' in the command text for each of the arguments and then executes that command. It returns each row of the result using the specified mapping. This function is only used by libraries in order to query the database via introspection. It is normally not used. More...
 

Static Public Member Functions

static void ResetPool ()
 Closes all connections to all async databases. You should never need to do this. This is a blocking operation that will return when all connections have been closed. More...
 

Public Attributes

string DatabasePath => GetConnection().DatabasePath
 Gets the database path used by this connection. More...
 
int LibVersionNumber => GetConnection().LibVersionNumber
 Gets the SQLite library version number. 3007014 would be v3.7.14 More...
 
string DateTimeStringFormat => GetConnection().DateTimeStringFormat
 The format to use when storing DateTime properties as strings. Ignored if StoreDateTimeAsTicks is true. More...
 
bool StoreDateTimeAsTicks => GetConnection().StoreDateTimeAsTicks
 Whether to store DateTime properties as ticks (true) or strings (false). More...
 
bool StoreTimeSpanAsTicks => GetConnection().StoreTimeSpanAsTicks
 Whether to store TimeSpan properties as ticks (true) or strings (false). More...
 
IEnumerable< TableMappingTableMappings => GetConnection().TableMappings
 Returns the mappings from types to tables that the connection currently understands. More...
 

Properties

bool Trace [get, set]
 Whether to writer queries to Tracer during execution. More...
 
Action< string > Tracer [get, set]
 The delegate responsible for writing trace lines. More...
 
bool TimeExecution [get, set]
 Whether Trace lines should be written that show the execution time of queries. More...
 

Detailed Description

A pooled asynchronous connection to a SQLite database.

Constructor & Destructor Documentation

◆ SQLiteAsyncConnection() [1/3]

SQLite.SQLiteAsyncConnection.SQLiteAsyncConnection ( string  databasePath,
bool  storeDateTimeAsTicks = true 
)

Constructs a new SQLiteAsyncConnection and opens a pooled SQLite database specified by databasePath.

Parameters
databasePathSpecifies the path to the database file.
storeDateTimeAsTicksSpecifies whether to store DateTime properties as ticks (true) or strings (false). You absolutely do want to store them as Ticks in all new projects. The value of false is only here for backwards compatibility. There is a significant speed advantage, with no down sides, when setting storeDateTimeAsTicks = true. If you use DateTimeOffset properties, it will be always stored as ticks regardingless the storeDateTimeAsTicks parameter.

◆ SQLiteAsyncConnection() [2/3]

SQLite.SQLiteAsyncConnection.SQLiteAsyncConnection ( string  databasePath,
SQLiteOpenFlags  openFlags,
bool  storeDateTimeAsTicks = true 
)

Constructs a new SQLiteAsyncConnection and opens a pooled SQLite database specified by databasePath.

Parameters
databasePathSpecifies the path to the database file.
openFlagsFlags controlling how the connection should be opened. Async connections should have the FullMutex flag set to provide best performance.
storeDateTimeAsTicksSpecifies whether to store DateTime properties as ticks (true) or strings (false). You absolutely do want to store them as Ticks in all new projects. The value of false is only here for backwards compatibility. There is a significant speed advantage, with no down sides, when setting storeDateTimeAsTicks = true. If you use DateTimeOffset properties, it will be always stored as ticks regardingless the storeDateTimeAsTicks parameter.

◆ SQLiteAsyncConnection() [3/3]

SQLite.SQLiteAsyncConnection.SQLiteAsyncConnection ( SQLiteConnectionString  connectionString)

Constructs a new SQLiteAsyncConnection and opens a pooled SQLite database using the given connection string.

Parameters
connectionStringDetails on how to find and open the database.

Member Function Documentation

◆ BackupAsync()

Task SQLite.SQLiteAsyncConnection.BackupAsync ( string  destinationDatabasePath,
string  databaseName = "main" 
)

Backup the entire database to the specified path.

Parameters
destinationDatabasePathPath to backup file.
databaseNameThe name of the database to backup (usually "main").

◆ CloseAsync()

Task SQLite.SQLiteAsyncConnection.CloseAsync ( )

Closes any pooled connections used by the database.

◆ CreateIndexAsync() [1/4]

Task<int> SQLite.SQLiteAsyncConnection.CreateIndexAsync ( string  indexName,
string  tableName,
string  columnName,
bool  unique = false 
)

Creates an index for the specified table and column.

Parameters
indexNameName of the index to create
tableNameName of the database table
columnNameName of the column to index
uniqueWhether the index should be unique

◆ CreateIndexAsync() [2/4]

Task<int> SQLite.SQLiteAsyncConnection.CreateIndexAsync ( string  indexName,
string  tableName,
string[]  columnNames,
bool  unique = false 
)

Creates an index for the specified table and columns.

Parameters
indexNameName of the index to create
tableNameName of the database table
columnNamesAn array of column names to index
uniqueWhether the index should be unique

◆ CreateIndexAsync() [3/4]

Task<int> SQLite.SQLiteAsyncConnection.CreateIndexAsync ( string  tableName,
string  columnName,
bool  unique = false 
)

Creates an index for the specified table and column.

Parameters
tableNameName of the database table
columnNameName of the column to index
uniqueWhether the index should be unique

◆ CreateIndexAsync() [4/4]

Task<int> SQLite.SQLiteAsyncConnection.CreateIndexAsync ( string  tableName,
string[]  columnNames,
bool  unique = false 
)

Creates an index for the specified table and columns.

Parameters
tableNameName of the database table
columnNamesAn array of column names to index
uniqueWhether the index should be unique

◆ CreateIndexAsync< T >()

Task<int> SQLite.SQLiteAsyncConnection.CreateIndexAsync< T > ( Expression< Func< T, object >>  property,
bool  unique = false 
)

Creates an index for the specified object property. e.g. CreateIndex<Client>(c => c.Name);

Template Parameters
TType to reflect to a database table.
Parameters
propertyProperty to index
uniqueWhether the index should be unique

◆ CreateTableAsync()

Task<CreateTableResult> SQLite.SQLiteAsyncConnection.CreateTableAsync ( Type  ty,
CreateFlags  createFlags = CreateFlags.None 
)

Executes a "create table if not exists" on the database. It also creates any specified indexes on the columns of the table. It uses a schema automatically generated from the specified type. You can later access this schema by calling GetMapping.

Parameters
tyType to reflect to a database table.
createFlagsOptional flags allowing implicit PK and indexes based on naming conventions.


Returns
Whether the table was created or migrated.

◆ CreateTableAsync< T >()

Executes a "create table if not exists" on the database. It also creates any specified indexes on the columns of the table. It uses a schema automatically generated from the specified type. You can later access this schema by calling GetMapping.

Returns
Whether the table was created or migrated.
Type Constraints
T :new() 

◆ CreateTablesAsync()

Task<CreateTablesResult> SQLite.SQLiteAsyncConnection.CreateTablesAsync ( CreateFlags  createFlags = CreateFlags.None,
params Type[]  types 
)

Executes a "create table if not exists" on the database for each type. It also creates any specified indexes on the columns of the table. It uses a schema automatically generated from the specified type. You can later access this schema by calling GetMapping.

Returns
Whether the table was created or migrated for each type.

◆ CreateTablesAsync< T, T2 >()

Executes a "create table if not exists" on the database for each type. It also creates any specified indexes on the columns of the table. It uses a schema automatically generated from the specified type. You can later access this schema by calling GetMapping.

Returns
Whether the table was created or migrated for each type.
Type Constraints
T :new() 
T2 :new() 

◆ CreateTablesAsync< T, T2, T3 >()

Executes a "create table if not exists" on the database for each type. It also creates any specified indexes on the columns of the table. It uses a schema automatically generated from the specified type. You can later access this schema by calling GetMapping.

Returns
Whether the table was created or migrated for each type.
Type Constraints
T :new() 
T2 :new() 
T3 :new() 

◆ CreateTablesAsync< T, T2, T3, T4 >()

Executes a "create table if not exists" on the database for each type. It also creates any specified indexes on the columns of the table. It uses a schema automatically generated from the specified type. You can later access this schema by calling GetMapping.

Returns
Whether the table was created or migrated for each type.
Type Constraints
T :new() 
T2 :new() 
T3 :new() 
T4 :new() 

◆ CreateTablesAsync< T, T2, T3, T4, T5 >()

Executes a "create table if not exists" on the database for each type. It also creates any specified indexes on the columns of the table. It uses a schema automatically generated from the specified type. You can later access this schema by calling GetMapping.

Returns
Whether the table was created or migrated for each type.
Type Constraints
T :new() 
T2 :new() 
T3 :new() 
T4 :new() 
T5 :new() 

◆ DeferredQueryAsync()

Task<IEnumerable<object> > SQLite.SQLiteAsyncConnection.DeferredQueryAsync ( TableMapping  map,
string  query,
params object[]  args 
)

Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?' in the command text for each of the arguments and then executes that command. It returns each row of the result using the specified mapping. This function is only used by libraries in order to query the database via introspection. It is normally not used.

Parameters
mapA TableMapping to use to convert the resulting rows into objects.
queryThe fully escaped SQL.
argsArguments to substitute for the occurences of '?' in the query.
Returns
An enumerable with one result for each row returned by the query. The enumerator will call sqlite3_step on each call to MoveNext, so the database connection must remain open for the lifetime of the enumerator.

◆ DeferredQueryAsync< T >()

Task<IEnumerable<T> > SQLite.SQLiteAsyncConnection.DeferredQueryAsync< T > ( string  query,
params object[]  args 
)

Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?' in the command text for each of the arguments and then executes that command. It returns each row of the result using the mapping automatically generated for the given type.

Parameters
queryThe fully escaped SQL.
argsArguments to substitute for the occurences of '?' in the query.
Returns
An enumerable with one result for each row returned by the query. The enumerator will call sqlite3_step on each call to MoveNext, so the database connection must remain open for the lifetime of the enumerator.
Type Constraints
T :new() 

◆ DeleteAllAsync()

Task<int> SQLite.SQLiteAsyncConnection.DeleteAllAsync ( TableMapping  map)

Deletes all the objects from the specified table. WARNING WARNING: Let me repeat. It deletes ALL the objects from the specified table. Do you really want to do that?

Parameters
mapThe TableMapping used to identify the table.
Returns
The number of objects deleted.

◆ DeleteAllAsync< T >()

Deletes all the objects from the specified table. WARNING WARNING: Let me repeat. It deletes ALL the objects from the specified table. Do you really want to do that?

Returns
The number of objects deleted.
Template Parameters
TThe type of objects to delete.

◆ DeleteAsync() [1/2]

Task<int> SQLite.SQLiteAsyncConnection.DeleteAsync ( object  objectToDelete)

Deletes the given object from the database using its primary key.

Parameters
objectToDeleteThe object to delete. It must have a primary key designated using the PrimaryKeyAttribute.
Returns
The number of rows deleted.

◆ DeleteAsync() [2/2]

Task<int> SQLite.SQLiteAsyncConnection.DeleteAsync ( object  primaryKey,
TableMapping  map 
)

Deletes the object with the specified primary key.

Parameters
primaryKeyThe primary key of the object to delete.
mapThe TableMapping used to identify the table.
Returns
The number of objects deleted.

◆ DeleteAsync< T >()

Task<int> SQLite.SQLiteAsyncConnection.DeleteAsync< T > ( object  primaryKey)

Deletes the object with the specified primary key.

Parameters
primaryKeyThe primary key of the object to delete.
Returns
The number of objects deleted.
Template Parameters
TThe type of object.

◆ DropTableAsync()

Task<int> SQLite.SQLiteAsyncConnection.DropTableAsync ( TableMapping  map)

Executes a "drop table" on the database. This is non-recoverable.

Parameters
mapThe TableMapping used to identify the table.

◆ DropTableAsync< T >()

Executes a "drop table" on the database. This is non-recoverable.

Type Constraints
T :new() 

◆ EnableLoadExtensionAsync()

Task SQLite.SQLiteAsyncConnection.EnableLoadExtensionAsync ( bool  enabled)

Enable or disable extension loading.

◆ EnableWriteAheadLoggingAsync()

Task SQLite.SQLiteAsyncConnection.EnableWriteAheadLoggingAsync ( )

Enables the write ahead logging. WAL is significantly faster in most scenarios by providing better concurrency and better disk IO performance than the normal journal mode. You only need to call this function once in the lifetime of the database.

◆ ExecuteAsync()

Task<int> SQLite.SQLiteAsyncConnection.ExecuteAsync ( string  query,
params object[]  args 
)

Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?' in the command text for each of the arguments and then executes that command. Use this method instead of Query when you don't expect rows back. Such cases include INSERTs, UPDATEs, and DELETEs. You can set the Trace or TimeExecution properties of the connection to profile execution.

Parameters
queryThe fully escaped SQL.
argsArguments to substitute for the occurences of '?' in the query.
Returns
The number of rows modified in the database as a result of this execution.

◆ ExecuteScalarAsync< T >()

Task<T> SQLite.SQLiteAsyncConnection.ExecuteScalarAsync< T > ( string  query,
params object[]  args 
)

Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?' in the command text for each of the arguments and then executes that command. Use this method when return primitive values. You can set the Trace or TimeExecution properties of the connection to profile execution.

Parameters
queryThe fully escaped SQL.
argsArguments to substitute for the occurences of '?' in the query.
Returns
The number of rows modified in the database as a result of this execution.

◆ FindAsync()

Task<object> SQLite.SQLiteAsyncConnection.FindAsync ( object  pk,
TableMapping  map 
)

Attempts to retrieve an object with the given primary key from the table associated with the specified type. Use of this method requires that the given type have a designated PrimaryKey (using the PrimaryKeyAttribute).

Parameters
pkThe primary key.
mapThe TableMapping used to identify the table.
Returns
The object with the given primary key or null if the object is not found.

◆ FindAsync< T >() [1/2]

Task<T> SQLite.SQLiteAsyncConnection.FindAsync< T > ( Expression< Func< T, bool >>  predicate)

Attempts to retrieve the first object that matches the predicate from the table associated with the specified type.

Parameters
predicateA predicate for which object to find.
Returns
The object that matches the given predicate or null if the object is not found.
Type Constraints
T :new() 

◆ FindAsync< T >() [2/2]

Task<T> SQLite.SQLiteAsyncConnection.FindAsync< T > ( object  pk)

Attempts to retrieve an object with the given primary key from the table associated with the specified type. Use of this method requires that the given type have a designated PrimaryKey (using the PrimaryKeyAttribute).

Parameters
pkThe primary key.
Returns
The object with the given primary key or null if the object is not found.
Type Constraints
T :new() 

◆ FindWithQueryAsync()

Task<object> SQLite.SQLiteAsyncConnection.FindWithQueryAsync ( TableMapping  map,
string  query,
params object[]  args 
)

Attempts to retrieve the first object that matches the query from the table associated with the specified type.

Parameters
mapThe TableMapping used to identify the table.
queryThe fully escaped SQL.
argsArguments to substitute for the occurences of '?' in the query.
Returns
The object that matches the given predicate or null if the object is not found.

◆ FindWithQueryAsync< T >()

Task<T> SQLite.SQLiteAsyncConnection.FindWithQueryAsync< T > ( string  query,
params object[]  args 
)

Attempts to retrieve the first object that matches the query from the table associated with the specified type.

Parameters
queryThe fully escaped SQL.
argsArguments to substitute for the occurences of '?' in the query.
Returns
The object that matches the given predicate or null if the object is not found.
Type Constraints
T :new() 

◆ GetAsync()

Task<object> SQLite.SQLiteAsyncConnection.GetAsync ( object  pk,
TableMapping  map 
)

Attempts to retrieve an object with the given primary key from the table associated with the specified type. Use of this method requires that the given type have a designated PrimaryKey (using the PrimaryKeyAttribute).

Parameters
pkThe primary key.
mapThe TableMapping used to identify the table.
Returns
The object with the given primary key. Throws a not found exception if the object is not found.

◆ GetAsync< T >() [1/2]

Task<T> SQLite.SQLiteAsyncConnection.GetAsync< T > ( Expression< Func< T, bool >>  predicate)

Attempts to retrieve the first object that matches the predicate from the table associated with the specified type.

Parameters
predicateA predicate for which object to find.
Returns
The object that matches the given predicate. Throws a not found exception if the object is not found.
Type Constraints
T :new() 

◆ GetAsync< T >() [2/2]

Task<T> SQLite.SQLiteAsyncConnection.GetAsync< T > ( object  pk)

Attempts to retrieve an object with the given primary key from the table associated with the specified type. Use of this method requires that the given type have a designated PrimaryKey (using the PrimaryKeyAttribute).

Parameters
pkThe primary key.
Returns
The object with the given primary key. Throws a not found exception if the object is not found.
Type Constraints
T :new() 

◆ GetBusyTimeout()

TimeSpan SQLite.SQLiteAsyncConnection.GetBusyTimeout ( )

The amount of time to wait for a table to become unlocked.

◆ GetConnection()

SQLiteConnectionWithLock SQLite.SQLiteAsyncConnection.GetConnection ( )

Gets the pooled lockable connection used by this async connection. You should never need to use this. This is provided only to add additional functionality to SQLite-net. If you use this connection, you must use the Lock method on it while using it.

◆ GetMappingAsync()

Task<TableMapping> SQLite.SQLiteAsyncConnection.GetMappingAsync ( Type  type,
CreateFlags  createFlags = CreateFlags.None 
)

Retrieves the mapping that is automatically generated for the given type.

Parameters
typeThe type whose mapping to the database is returned.


Parameters
createFlagsOptional flags allowing implicit PK and indexes based on naming conventions


Returns
The mapping represents the schema of the columns of the database and contains methods to set and get properties of objects.

◆ GetMappingAsync< T >()

Retrieves the mapping that is automatically generated for the given type.

Parameters
createFlagsOptional flags allowing implicit PK and indexes based on naming conventions


Returns
The mapping represents the schema of the columns of the database and contains methods to set and get properties of objects.
Type Constraints
T :new() 

◆ GetTableInfoAsync()

Task<List<SQLiteConnection.ColumnInfo> > SQLite.SQLiteAsyncConnection.GetTableInfoAsync ( string  tableName)

Query the built-in sqlite table_info table for a specific tables columns.

Returns
The columns contains in the table.
Parameters
tableNameTable name.

◆ InsertAllAsync() [1/3]

Task<int> SQLite.SQLiteAsyncConnection.InsertAllAsync ( IEnumerable  objects,
bool  runInTransaction = true 
)

Inserts all specified objects.

Parameters
objectsAn IEnumerable of the objects to insert.
Parameters
runInTransactionA boolean indicating if the inserts should be wrapped in a transaction.
Returns
The number of rows added to the table.

◆ InsertAllAsync() [2/3]

Task<int> SQLite.SQLiteAsyncConnection.InsertAllAsync ( IEnumerable  objects,
string  extra,
bool  runInTransaction = true 
)

Inserts all specified objects.

Parameters
objectsAn IEnumerable of the objects to insert.
extraLiteral SQL code that gets placed into the command. INSERT {extra} INTO ...
runInTransactionA boolean indicating if the inserts should be wrapped in a transaction.
Returns
The number of rows added to the table.

◆ InsertAllAsync() [3/3]

Task<int> SQLite.SQLiteAsyncConnection.InsertAllAsync ( IEnumerable  objects,
Type  objType,
bool  runInTransaction = true 
)

Inserts all specified objects.

Parameters
objectsAn IEnumerable of the objects to insert.
objTypeThe type of object to insert.
runInTransactionA boolean indicating if the inserts should be wrapped in a transaction.
Returns
The number of rows added to the table.

◆ InsertAsync() [1/4]

Task<int> SQLite.SQLiteAsyncConnection.InsertAsync ( object  obj)

Inserts the given object and retrieves its auto incremented primary key if it has one.

Parameters
objThe object to insert.
Returns
The number of rows added to the table.

◆ InsertAsync() [2/4]

Task<int> SQLite.SQLiteAsyncConnection.InsertAsync ( object  obj,
string  extra 
)

Inserts the given object (and updates its auto incremented primary key if it has one). The return value is the number of rows added to the table.

Parameters
objThe object to insert.
extraLiteral SQL code that gets placed into the command. INSERT {extra} INTO ...
Returns
The number of rows added to the table.

◆ InsertAsync() [3/4]

Task<int> SQLite.SQLiteAsyncConnection.InsertAsync ( object  obj,
string  extra,
Type  objType 
)

Inserts the given object (and updates its auto incremented primary key if it has one). The return value is the number of rows added to the table.

Parameters
objThe object to insert.
extraLiteral SQL code that gets placed into the command. INSERT {extra} INTO ...
objTypeThe type of object to insert.
Returns
The number of rows added to the table.

◆ InsertAsync() [4/4]

Task<int> SQLite.SQLiteAsyncConnection.InsertAsync ( object  obj,
Type  objType 
)

Inserts the given object (and updates its auto incremented primary key if it has one). The return value is the number of rows added to the table.

Parameters
objThe object to insert.
objTypeThe type of object to insert.
Returns
The number of rows added to the table.

◆ InsertOrReplaceAsync() [1/2]

Task<int> SQLite.SQLiteAsyncConnection.InsertOrReplaceAsync ( object  obj)

Inserts the given object (and updates its auto incremented primary key if it has one). The return value is the number of rows added to the table. If a UNIQUE constraint violation occurs with some pre-existing object, this function deletes the old object.

Parameters
objThe object to insert.
Returns
The number of rows modified.

◆ InsertOrReplaceAsync() [2/2]

Task<int> SQLite.SQLiteAsyncConnection.InsertOrReplaceAsync ( object  obj,
Type  objType 
)

Inserts the given object (and updates its auto incremented primary key if it has one). The return value is the number of rows added to the table. If a UNIQUE constraint violation occurs with some pre-existing object, this function deletes the old object.

Parameters
objThe object to insert.
objTypeThe type of object to insert.
Returns
The number of rows modified.

◆ QueryAsync()

Task<List<object> > SQLite.SQLiteAsyncConnection.QueryAsync ( TableMapping  map,
string  query,
params object[]  args 
)

Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?' in the command text for each of the arguments and then executes that command. It returns each row of the result using the specified mapping. This function is only used by libraries in order to query the database via introspection. It is normally not used.

Parameters
mapA TableMapping to use to convert the resulting rows into objects.
queryThe fully escaped SQL.
argsArguments to substitute for the occurences of '?' in the query.
Returns
An enumerable with one result for each row returned by the query.

◆ QueryAsync< T >()

Task<List<T> > SQLite.SQLiteAsyncConnection.QueryAsync< T > ( string  query,
params object[]  args 
)

Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?' in the command text for each of the arguments and then executes that command. It returns each row of the result using the mapping automatically generated for the given type.

Parameters
queryThe fully escaped SQL.
argsArguments to substitute for the occurences of '?' in the query.
Returns
A list with one result for each row returned by the query.
Type Constraints
T :new() 

◆ QueryScalarsAsync< T >()

Task<List<T> > SQLite.SQLiteAsyncConnection.QueryScalarsAsync< T > ( string  query,
params object[]  args 
)

Creates a SQLiteCommand given the command text (SQL) with arguments. Place a '?' in the command text for each of the arguments and then executes that command. It returns the first column of each row of the result.

Parameters
queryThe fully escaped SQL.
argsArguments to substitute for the occurences of '?' in the query.
Returns
A list with one result for the first column of each row returned by the query.

◆ ResetPool()

static void SQLite.SQLiteAsyncConnection.ResetPool ( )
static

Closes all connections to all async databases. You should never need to do this. This is a blocking operation that will return when all connections have been closed.

◆ RunInTransactionAsync()

Task SQLite.SQLiteAsyncConnection.RunInTransactionAsync ( Action< SQLiteConnection action)

Executes action within a (possibly nested) transaction by wrapping it in a SAVEPOINT. If an exception occurs the whole transaction is rolled back, not just the current savepoint. The exception is rethrown.

Parameters
actionThe Action to perform within a transaction. action can contain any number of operations on the connection but should never call SQLiteConnection.Commit or SQLiteConnection.Commit.

◆ SetBusyTimeoutAsync()

Task SQLite.SQLiteAsyncConnection.SetBusyTimeoutAsync ( TimeSpan  value)

Sets the amount of time to wait for a table to become unlocked.

◆ Table< T >()

AsyncTableQuery<T> SQLite.SQLiteAsyncConnection.Table< T > ( )

Returns a queryable interface to the table represented by the given type.

Returns
A queryable object that is able to translate Where, OrderBy, and Take queries into native SQL.
Type Constraints
T :new() 

◆ UpdateAllAsync()

Task<int> SQLite.SQLiteAsyncConnection.UpdateAllAsync ( IEnumerable  objects,
bool  runInTransaction = true 
)

Updates all specified objects.

Parameters
objectsAn IEnumerable of the objects to insert.
runInTransactionA boolean indicating if the inserts should be wrapped in a transaction
Returns
The number of rows modified.

◆ UpdateAsync() [1/2]

Task<int> SQLite.SQLiteAsyncConnection.UpdateAsync ( object  obj)

Updates all of the columns of a table using the specified object except for its primary key. The object is required to have a primary key.

Parameters
objThe object to update. It must have a primary key designated using the PrimaryKeyAttribute.
Returns
The number of rows updated.

◆ UpdateAsync() [2/2]

Task<int> SQLite.SQLiteAsyncConnection.UpdateAsync ( object  obj,
Type  objType 
)

Updates all of the columns of a table using the specified object except for its primary key. The object is required to have a primary key.

Parameters
objThe object to update. It must have a primary key designated using the PrimaryKeyAttribute.
objTypeThe type of object to insert.
Returns
The number of rows updated.

Member Data Documentation

◆ DatabasePath

string SQLite.SQLiteAsyncConnection.DatabasePath => GetConnection().DatabasePath

Gets the database path used by this connection.

◆ DateTimeStringFormat

string SQLite.SQLiteAsyncConnection.DateTimeStringFormat => GetConnection().DateTimeStringFormat

The format to use when storing DateTime properties as strings. Ignored if StoreDateTimeAsTicks is true.

The date time string format.

◆ LibVersionNumber

int SQLite.SQLiteAsyncConnection.LibVersionNumber => GetConnection().LibVersionNumber

Gets the SQLite library version number. 3007014 would be v3.7.14

◆ StoreDateTimeAsTicks

bool SQLite.SQLiteAsyncConnection.StoreDateTimeAsTicks => GetConnection().StoreDateTimeAsTicks

Whether to store DateTime properties as ticks (true) or strings (false).

◆ StoreTimeSpanAsTicks

bool SQLite.SQLiteAsyncConnection.StoreTimeSpanAsTicks => GetConnection().StoreTimeSpanAsTicks

Whether to store TimeSpan properties as ticks (true) or strings (false).

◆ TableMappings

IEnumerable<TableMapping> SQLite.SQLiteAsyncConnection.TableMappings => GetConnection().TableMappings

Returns the mappings from types to tables that the connection currently understands.

Property Documentation

◆ TimeExecution

bool SQLite.SQLiteAsyncConnection.TimeExecution
getset

Whether Trace lines should be written that show the execution time of queries.

◆ Trace

bool SQLite.SQLiteAsyncConnection.Trace
getset

Whether to writer queries to Tracer during execution.

The tracer.

◆ Tracer

Action<string> SQLite.SQLiteAsyncConnection.Tracer
getset

The delegate responsible for writing trace lines.

The tracer.


The documentation for this class was generated from the following file: