Skip to content

SqlHelper class

namespace: Serenity.Data   assemblySerenity.Net.Services

Contains static SQL related helper functions and extensions.

public static class SqlHelper

Public Members

name description
static AddParamWithValue(…) Adds the parameter with value to the target command.
static Execute(…) Executes the specified query on the connection. (3 methods)
static ExecuteAndGetID(…) Executes the query and returns the generated identity value. Only works for auto incremented fields, not GUIDs.
static ExecuteAndGetIDAsync(…) Executes the query asynchronously and returns the generated identity value. Only works for auto incremented fields, not GUIDs.
static ExecuteAsync(…) Executes the specified query on the connection asynchronously. (3 methods)
static ExecuteNonQuery(…) Executes the statement.
static ExecuteNonQueryAsync(…) Executes the statement asynchronously.
static ExecuteReader(…) Executes the command returning a data reader. (2 methods)
static ExecuteReaderAsync(…) Executes the command asynchronously returning a data reader. (2 methods)
static ExecuteScalar(…) Executes the statement returning a scalar value. (2 methods)
static ExecuteScalarAsync(…) Executes the statement asynchronously returning a scalar value. (2 methods)
static ExecuteUpsert(…) Executes an UPSERT (insert or update) query on the connection and returns the number of affected rows. The key fields are used to determine whether an existing record is updated or a new record is inserted.
static ExecuteUpsertAsync(…) Executes an UPSERT (insert or update) query on the connection asynchronously and returns the number of affected rows. The key fields are used to determine whether an existing record is updated or a new record is inserted.
static Exists(…) Executes the query returning true if it has at least one result.
static ExistsAsync(…) Executes the query asynchronously returning true if it has at least one result.
static FixParamType(…) Fixes the type of the parameter to something suitable as a SQL parameter.
static LogCommand(…) Logs the command.
static NewCommand(…) Creates a new command. (2 methods)

See Also