Table of Contents

Method GetOptional

Namespace
PowerSync.Common.MDSQLite
Assembly
PowerSync.Common.dll

GetOptional(string, object?[]?)

Executes a read-only query and returns the first row, or null if there are no rows.

public Task<IQueryRow?> GetOptional(string query, object?[]? parameters = null)

Parameters

query string
parameters object[]

Returns

Task<IQueryRow>

GetOptional<T>(string, object?[]?, SqlMapper<T>)

Executes a read-only query and returns the first row mapped using mapper, or default(T) if there are no rows. Note that default(T) is not null for all types. Map to a nullable type (e.g. row => (long?)row.GetLong("id")) to ensure you get null.

public Task<T?> GetOptional<T>(string query, object?[]? parameters, SqlMapper<T> mapper)

Parameters

query string
parameters object[]
mapper SqlMapper<T>

Returns

Task<T>

Type Parameters

T

GetOptional<T>(string, object?[]?)

Executes a read-only query and returns the first row mapped using T.FromRow, or default(T) if there are no rows. Note that default(T) is not null if T is a value type.

public Task<T?> GetOptional<T>(string query, object?[]? parameters = null) where T : IFromRow<T>

Parameters

query string
parameters object[]

Returns

Task<T>

Type Parameters

T