Query Interface

Represents a query.

C#
public interface Query

Methods

SelectAllFrom<T>(string)

Selects all columns of the specified table.

Select<T>(string[])

Gets the Select<T>(string[]) object to select the specified columns of the specified table.

Update<T>(string)

Gets the Update object to update the specified table.

DeleteFrom<T>()

Gets the DeleteFrom<T>() object to delete the specified rows of the specified table.

NewTables(Type[])

Creates new tables.

NewTables(IEnumerable<Type>)

Creates new tables.

Insert<T>(T)

Inserts a new row into the table.

InsertAndGetRowId<T>(T)

Inserts a new row into the table and gets its ID.

SelectUnique<T>(string, object)

Gets the single row of the table in which the specified unique field matches the specified value.

SelectAll<T>()

Gets all the rows of the specified table.

ColumnName<T>(string)

Gets the column name associated with the specified parameter.

Methods Detail

SelectAllFrom<T>(string)

Selects all columns of the specified table.

C#
SelectFrom<T> SelectAllFrom<T>(string alias)

Type Parameters

T
notnull

The type qualified with TableAttribute.

Parameters

alias
string

The alias of the table name.

Returns

Select<T>(string[])

Gets the Select<T>(string[]) object to select the specified columns of the specified table.

C#
Select<T> Select<T>(params string[] columns)

Type Parameters

T
notnull

The type representing the result of this query, which must have the single constructor accepting the parameters corresponding to columns.

Parameters

columns
string[]

One or more column names. Each consists of the alias followed by a period (.) and the column name.

Returns

Update<T>(string)

Gets the Update object to update the specified table.

C#
Update Update<T>(string alias)

Type Parameters

T
notnull

The type qualified with TableAttribute.

Parameters

alias
string

The alias of the table name, which can be used in the Where clause (see UpdateSet.Where(string)).

Returns

The Update object.

Examples

var kit = new TransactionKit(
    "update_example.db", m => Console.WriteLine(m()));
var map = new Dictionary<string, object>()
{
    ["$id"] = 2L,
    ["$newState"] = "Closed",
};
kit.Execute(q =>
{
    q.Update<Issue>("i")
        .Set("state = $newState")
        .Where("i.id = $id")
        .Execute(map);
});

DeleteFrom<T>()

Gets the DeleteFrom<T>() object to delete the specified rows of the specified table.

C#
DeleteFrom<T> DeleteFrom<T>()

Type Parameters

T
notnull

The type qualified with TableAttribute.

Returns

NewTables(Type[])

Creates new tables.

C#
void NewTables(params Type[] tables)

Parameters

tables
Type[]

The types qualified with TableAttribute representing the tables to create.

Remarks

This method drops the tables if they exist and then creates them newly.

NewTables(IEnumerable<Type>)

Creates new tables.

C#
void NewTables(IEnumerable<Type> allTables)

Parameters

allTables
IEnumerable<Type>

The types qualified with TableAttribute representing the tables to create.

Remarks

This method drops the tables if they exist and then creates them newly.

Insert<T>(T)

Inserts a new row into the table.

C#
void Insert<T>(T row)

Type Parameters

T
notnull

The type qualified with TableAttribute representing the table.

Parameters

row
T

The row of the table to add.

InsertAndGetRowId<T>(T)

Inserts a new row into the table and gets its ID.

C#
long InsertAndGetRowId<T>(T row)

Type Parameters

T
notnull

The type qualified with TableAttribute representing the table. It must have the field qualified with AutoIncrementAttribute.

Parameters

row
T

The row of the table to add.

Returns

The ID of the row newly inserted.

SelectUnique<T>(string, object)

Gets the single row of the table in which the specified unique field matches the specified value.

C#
T SelectUnique<T>(string columnName, object value)

Type Parameters

T
class

The type qualified with TableAttribute representing the table. It must have the field qualified with UniqueAttribute.

Parameters

columnName
string

The name of the unique field.

value
object

The value that the unique field matches.

Returns

T

The row in which the field specified with columnName matches the specified value if it exists, null otherwise.

SelectAll<T>()

Gets all the rows of the specified table.

C#
IEnumerable<T> SelectAll<T>()

Type Parameters

T
notnull

The type represents the row of the table.

Returns

All the rows of the specified table.

Remarks

The IEnumerable<T> object returned by this method is valid as long as the transaction is in progress. If you need access to it after the transaction, you must use something like the Enumerable.ToList<TSource>(IEnumerable<TSource>) method to get the list in the meantime and then use it afterward.

ColumnName<T>(string)

Gets the column name associated with the specified parameter.

C#
string ColumnName<T>(string parameterName)

Type Parameters

T
notnull

The type represents the row of the table.

Parameters

parameterName
string

The parameter name that the constructor of T contains.

Returns

The column name.