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

Class SqliteMemoryDatabase

Inheritance
System.Object
SqliteMemoryDatabase
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 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.String tableName

The name of the table to create

System.String[] 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.Action<System.Data.Common.DbConnection> 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

LoadFrom(SqliteDatabase)

Loads from a disk database to this in-memory database

Declaration
public void LoadFrom(SqliteDatabase database)
Parameters
Type Name Description
SqliteDatabase 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.Func<System.Data.Common.DbConnection, 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

SaveTo(SqliteDatabase)

Saves the in-memory databse to a real database

Declaration
public void SaveTo(SqliteDatabase database)
Parameters
Type Name Description
SqliteDatabase database

The real database to back up to

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