Interface ISqlDatabase
Represents a generic SQL database. Usually SQLite backed.
Namespace: Snowflake.Persistence
Assembly: Snowflake.Framework.Primitives.dll
Syntax
public interface ISqlDatabase
Properties
DatabaseName
Gets the file or connection name.
Declaration
string DatabaseName { get; }
Property Value
| Type | Description |
|---|---|
| System. |
Methods
CreateTable(String, String[])
Creates a table with the given name and column rows
Declaration
void CreateTable(string tableName, params string[] columns)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
tableName | The name of the table. |
| System. |
columns | The column directives. |
Execute(Action<IDbConnection>)
Executes an atomic query function on the database.
Declaration
void Execute(Action<IDbConnection> queryFunction)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
queryFunction | The query function on the database |
Execute(String, Object)
Executes a parameterized string query given an object representing paramaters.
Declaration
void Execute(string query, object param = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
query | The SQL string query |
| System. |
param | The object containing the parameters |
GetConnection()
Gets a connection to the database
Declaration
IDbConnection GetConnection()
Returns
| Type | Description |
|---|---|
| System. |
Query<T>(Func<IDbConnection, T>)
Executes a typed query given a query function that returns the object.
Declaration
T Query<T>(Func<IDbConnection, T> queryFunction)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
queryFunction | The query function that returns the object |
Returns
| Type | Description |
|---|---|
| T |
Type Parameters
| Name | Description |
|---|---|
| T | The return type of the object |
Query<T>(String, Object)
Executes a string query that returns an enumerable of matching objects.
Declaration
IEnumerable<T> Query<T>(string query, object param = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
query | The parameterized string query. |
| System. |
param | The object containing the parameters |
Returns
| Type | Description |
|---|---|
| System. |
An enumerable or matching objects |
Type Parameters
| Name | Description |
|---|---|
| T | The return type of the objects |
QueryFirstOrDefault<T>(String, Object)
Returns the first object given the string query, or null if no matching objects found.
Declaration
T QueryFirstOrDefault<T>(string query, object param = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System. |
query | The parameterized string query. |
| System. |
param | The object containing the parameters |
Returns
| Type | Description |
|---|---|
| T | The first object given the string query, or null if no matching objects found. |
Type Parameters
| Name | Description |
|---|---|
| T | The return type of the objects |