• Home
  • Blog
  • Docs
  • GitHub
Show / Hide Table of Contents

Class SqliteDatabase

Inheritance
System.Object
SqliteDatabase
Implements
ISqlDatabase
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
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.String fileName

Properties

DatabaseName

Declaration
public string DatabaseName { get; }
Property Value
Type Description
System.String

Methods

CreateTable(String, String[])

Creates a table in the database

Declaration
public void CreateTable(string tableName, params string[] columns)
Parameters
Type Name Description
System.String tableName

The name of the table to create

System.String[] 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.Action<System.Data.IDbConnection> 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.String query

The SQL query to execute

System.Object param

The query parameters

GetConnection()

Declaration
public IDbConnection GetConnection()
Returns
Type Description
System.Data.IDbConnection

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.Func<System.Data.IDbConnection, T> 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.String query

The SQL query to execute

System.Object param

The query parameters

Returns
Type Description
System.Collections.Generic.IEnumerable<T>

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.String query

The SQL query to execute

System.Object 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

Implements

ISqlDatabase
Built with ❤️ by @chyyran. Text content licensed under CC-BY-SA 4.0.