Class SqliteMemoryDatabase
Inheritance
Inherited Members
Namespace: Snowflake.Persistence
Assembly: Snowflake.Framework.dll
Syntax
public class SqliteMemoryDatabase
Constructors
SqliteMemoryDatabase()
Declaration
public SqliteMemoryDatabase()
Methods
CreateTable(String, String[])
Creates a table in the database
Declaration
public void CreateTable(string tableName, params string[] columns)
Parameters
Type | Name | Description |
---|---|---|
System. |
tableName | The name of the table to create |
System. |
columns | The names of the columns to create |
Execute(Action<DbConnection>)
Executes on a new connection to the database. The connection will be safely closed after the operation.
Declaration
public void Execute(Action<DbConnection> queryFunction)
Parameters
Type | Name | Description |
---|---|---|
System. |
queryFunction | A function to query the database using the opened connection |
Execute(String, Object)
Executes on a new connection to the database. The connection will be safely closed after the operation.
Declaration
public void Execute(string query, object param = null)
Parameters
Type | Name | Description |
---|---|---|
System. |
query | The SQL query to execute |
System. |
param | The query parameters |
LoadFrom(SqliteDatabase)
Loads from a disk database to this in-memory database
Declaration
public void LoadFrom(SqliteDatabase database)
Parameters
Type | Name | Description |
---|---|---|
Sqlite |
database | The database to load from |
Query<T>(Func<DbConnection, T>)
Queries on a new connection to the database. The connection will be safely closed after the operation.
Declaration
public T Query<T>(Func<DbConnection, T> queryFunction)
Parameters
Type | Name | Description |
---|---|---|
System. |
queryFunction | A function to query the database using the opened connection |
Returns
Type | Description |
---|---|
T | The requested data. |
Type Parameters
Name | Description |
---|---|
T | The type the query will return |
Query<T>(String, Object)
Queries on a new connection to the database. The connection will be safely closed after the operation.
Declaration
public IEnumerable<T> Query<T>(string query, object param = null)
Parameters
Type | Name | Description |
---|---|---|
System. |
query | The SQL query to execute |
System. |
param | The query parameters |
Returns
Type | Description |
---|---|
System. |
The requested data. |
Type Parameters
Name | Description |
---|---|
T | The type the query will return |
QueryFirstOrDefault<T>(String, Object)
Executes a single row query The connection will be safely closed after the operation.
Declaration
public T QueryFirstOrDefault<T>(string query, object param = null)
Parameters
Type | Name | Description |
---|---|---|
System. |
query | The SQL query to execute |
System. |
param | The query parameters |
Returns
Type | Description |
---|---|
T | The requested data, or null if not present. |
Type Parameters
Name | Description |
---|---|
T | The type the query will return |
SaveTo(SqliteDatabase)
Saves the in-memory databse to a real database
Declaration
public void SaveTo(SqliteDatabase database)
Parameters
Type | Name | Description |
---|---|---|
Sqlite |
database | The real database to back up to |