Class SqliteDatabase
Inheritance
Implements
Inherited Members
Namespace: Snowflake.Persistence
Assembly: Snowflake.Framework.dll
Syntax
public class SqliteDatabase : ISqlDatabase
Constructors
SqliteDatabase(String)
Declaration
public SqliteDatabase(string fileName)
Parameters
Type | Name | Description |
---|---|---|
System. |
fileName |
Properties
DatabaseName
Declaration
public string DatabaseName { get; }
Property Value
Type | Description |
---|---|
System. |
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<IDbConnection>)
Executes on a new connection to the database. The connection will be safely closed after the operation.
Declaration
public void Execute(Action<IDbConnection> 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 |
GetConnection()
Declaration
public IDbConnection GetConnection()
Returns
Type | Description |
---|---|
System. |
Query<T>(Func<IDbConnection, T>)
Queries on a new connection to the database. The connection will be safely closed after the operation.
Declaration
public T Query<T>(Func<IDbConnection, 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 |