Table of Contents

Class DataManager

Namespace
Cuemon.Data
Assembly
Cuemon.Data.dll

The DataManager is an abstract class in the Cuemon.Data namespace that can be used to implement execute commands of different database providers.

public abstract class DataManager : Configurable<DataManagerOptions>, IConfigurable<DataManagerOptions>
Inheritance
DataManager
Implements
Derived
Inherited Members

Constructors

DataManager(Action<DataManagerOptions>)

Initializes a new instance of the DataManager class.

protected DataManager(Action<DataManagerOptions> setup)

Parameters

setup Action<DataManagerOptions>

The DataManagerOptions which need to be configured.

Methods

Clone()

Creates a new object that is a copy of the current instance.

public abstract DataManager Clone()

Returns

DataManager

A new object that is a copy of this instance.

Execute(DataStatement)

Executes the command statement and returns the number of rows affected.

public int Execute(DataStatement statement)

Parameters

statement DataStatement

The command statement to execute.

Returns

Int32

A Int32 value.

ExecuteAsync(DataStatement, CancellationToken)

Asynchronously executes the command statement and returns the number of rows affected.

public Task<int> ExecuteAsync(DataStatement statement, CancellationToken ct = default(CancellationToken))

Parameters

statement DataStatement

The command statement to execute.

ct CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<Int32>

A task that represents the asynchronous operation. The task result contains the number of rows affected.

ExecuteCommand<T>(DataStatement, Func<IDbCommand, T>)

Core method for executing methods on the IDbCommand interface resolved from the abstract GetDbCommand(DataStatement) method.

protected virtual T ExecuteCommand<T>(DataStatement statement, Func<IDbCommand, T> executeSelector)

Parameters

statement DataStatement

The command statement to execute.

executeSelector Func<IDbCommand, T>

The function delegate that will invoke a method on the resolved IDbCommand from the abstract GetDbCommand(DataStatement) method.

Returns

T

A value of T that is equal to the invoked method of the IDbCommand implementation.

Type Parameters

T

The type to return.

ExecuteCommandAsync<T>(DataStatement, Func<DbCommand, Task<T>>)

Asynchronous core method for executing methods on the DbCommand resolved from the abstract GetDbCommand(DataStatement) method.

protected virtual async Task<T> ExecuteCommandAsync<T>(DataStatement statement, Func<DbCommand, Task<T>> executeSelector)

Parameters

statement DataStatement

The command statement to execute.

executeSelector Func<DbCommand, Task<T>>

The function delegate that will invoke a method on the resolved DbCommand from the abstract GetDbCommand(DataStatement) method.

Returns

Task<T>

A task that represents the asynchronous operation. The task result contains a value of T that is equal to the invoked method of DbCommand.

Type Parameters

T

The type to return.

ExecuteExists(DataStatement)

Executes the command statement and returns true if one or more records exists; otherwise false.

public bool ExecuteExists(DataStatement statement)

Parameters

statement DataStatement

The command statement to execute.

Returns

Boolean

A Boolean value.

ExecuteExistsAsync(DataStatement, CancellationToken)

Asynchronously executes the command statement and returns true if one or more records exists; otherwise false.

public async Task<bool> ExecuteExistsAsync(DataStatement statement, CancellationToken ct = default(CancellationToken))

Parameters

statement DataStatement

The command statement to execute.

ct CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<Boolean>

A task that represents the asynchronous operation. The task result contains a Boolean.

ExecuteReader(DataStatement)

Executes the command statement and returns an object supporting the IDataReader interface.

public IDataReader ExecuteReader(DataStatement statement)

Parameters

statement DataStatement

The command statement to execute.

Returns

IDataReader

An object supporting the IDataReader interface.

ExecuteReaderAsync(DataStatement, CancellationToken)

Asynchronously executes the command statement and returns a DbDataReader.

public Task<DbDataReader> ExecuteReaderAsync(DataStatement statement, CancellationToken ct = default(CancellationToken))

Parameters

statement DataStatement

The command statement to execute.

ct CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<DbDataReader>

A task that represents the asynchronous operation. The task result contains an instance of DbDataReader.

ExecuteScalar(DataStatement)

Executes the command statement, and returns the value from the first column of the first row in the result set. Additional columns or rows are ignored.

public object ExecuteScalar(DataStatement statement)

Parameters

statement DataStatement

The command statement to execute.

Returns

Object

The first column of the first row in the result from statement.

ExecuteScalarAs<TResult>(DataStatement, Action<ObjectFormattingOptions>)

Executes the command statement, and attempts to convert the first column of the first row in the result set to the specified TResult. Additional columns or rows are ignored.

public virtual TResult ExecuteScalarAs<TResult>(DataStatement statement, Action<ObjectFormattingOptions> setup = null)

Parameters

statement DataStatement

The command statement to execute.

setup Action<ObjectFormattingOptions>

The ObjectFormattingOptions which may be configured.

Returns

TResult

The first column of the first row in the result from statement as TResult.

Type Parameters

TResult

The type of the return value.

Remarks

This method uses InvariantCulture when casting the first column of the first row in the result from statement.

Exceptions

AggregateException

The first column of the first row in the result set could not be converted.

See Also

ExecuteScalarAsAsync<TResult>(DataStatement, Action<ObjectFormattingOptions>, CancellationToken)

Asynchronously executes the command statement, and attempts to convert the first column of the first row in the result set to the specified TResult. Additional columns or rows are ignored.

public virtual async Task<TResult> ExecuteScalarAsAsync<TResult>(DataStatement statement, Action<ObjectFormattingOptions> setup = null, CancellationToken ct = default(CancellationToken))

Parameters

statement DataStatement

The command statement to execute.

setup Action<ObjectFormattingOptions>

The ObjectFormattingOptions which may be configured.

ct CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<TResult>

A task that represents the asynchronous operation. The task result contains the first column of the first column of the first row in the result from statement as TResult.

Type Parameters

TResult

The type of the return value.

Remarks

This method uses InvariantCulture when casting the first column of the first row in the result from statement.

Exceptions

AggregateException

The first column of the first row in the result set could not be converted.

See Also

ExecuteScalarAsType(DataStatement, Type, Action<ObjectFormattingOptions>)

Executes the command statement, and attempts to convert the first column of the first row in the result set to the specified returnType. Additional columns or rows are ignored.

public virtual object ExecuteScalarAsType(DataStatement statement, Type returnType, Action<ObjectFormattingOptions> setup = null)

Parameters

statement DataStatement

The command statement to execute.

returnType Type

The type to return the first column value as.

setup Action<ObjectFormattingOptions>

The ObjectFormattingOptions which needs to be configured.

Returns

Object

The first column of the first row in the result from statement as the specified returnType.

ExecuteScalarAsTypeAsync(DataStatement, Type, Action<ObjectFormattingOptions>, CancellationToken)

Asynchronously executes the command statement, and attempts to convert the first column of the first row in the result set to the specified returnType. Additional columns or rows are ignored.

public virtual async Task<object> ExecuteScalarAsTypeAsync(DataStatement statement, Type returnType, Action<ObjectFormattingOptions> setup = null, CancellationToken ct = default(CancellationToken))

Parameters

statement DataStatement

The command statement to execute.

returnType Type

The type to return the first column value as.

setup Action<ObjectFormattingOptions>

The ObjectFormattingOptions which may be configured.

ct CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<Object>

A task that represents the asynchronous operation. The task result contains the first column of the first column of the first row in the result from statement as the specified returnType.

ExecuteScalarAsync(DataStatement, CancellationToken)

Asynchronously executes the command statement, and returns the value from the first column of the first row in the result set. Additional columns or rows are ignored.

public Task<object> ExecuteScalarAsync(DataStatement statement, CancellationToken ct = default(CancellationToken))

Parameters

statement DataStatement

The command statement to execute.

ct CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<Object>

A task that represents the asynchronous operation. The task result contains the first column of the first row in the result from statement.

ExecuteString(DataStatement)

Executes the command statement and returns a String.

public virtual string ExecuteString(DataStatement statement)

Parameters

statement DataStatement

The command statement to execute.

Returns

String

A String object.

ExecuteStringAsync(DataStatement, CancellationToken)

Asynchronously executes the command statement and returns a String.

public virtual async Task<string> ExecuteStringAsync(DataStatement statement, CancellationToken ct = default(CancellationToken))

Parameters

statement DataStatement

The command statement to execute.

ct CancellationToken

A token to cancel the asynchronous operation.

Returns

Task<String>

A task that represents the asynchronous operation. The task result contains a String.

GetDbCommand(DataStatement)

Gets the command object to be used by all execute related methods.

protected abstract IDbCommand GetDbCommand(DataStatement statement)

Parameters

statement DataStatement

The command statement to execute.

Returns

IDbCommand

An instance of a IDbCommand implementation.