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

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

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

The name of the table.

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

The SQL string query

System.Object param

The object containing the parameters

GetConnection()

Gets a connection to the database

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

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

The parameterized string query.

System.Object param

The object containing the parameters

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

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

The parameterized string query.

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

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