Data/CafeLib.Data.Sources/SqlCommandProvider.cs
/// <summary>
/// Execute sql command to save an entry.
/// </summary>
/// <typeparam name="TKey">Entity key</typeparam>
/// <param name="connectionInfo">Connection info</param>
/// <param name="sql">Sql query</param>
/// <param name="parameters">Sql parameters</param>
/// <param name="token">Cancellation token</param>
/// <returns>Save result</returns>
Execute sql command to save an entry.
Execute sql command to save an entry .
public async Task<SaveResult<TKey>> ExecuteSaveAsync<TKey>(IConnectionInfo connectionInfo, string sql, object parameters, CancellationToken token = default)
        {
            await using var connection = connectionInfo.GetConnection<T>();
            var result = await connection.ExecuteScalarAsync(sql, parameters, cancellationToken: token).ConfigureAwait(false);
            return result != null ? new SaveResult<TKey>((TKey)result, true) : new SaveResult<TKey>((TKey)DefaultSqlId<TKey>());
        }
public async Task < SaveResult < TKey > > ExecuteSaveAsync < TKey > ( IConnectionInfo connectionInfo , string sql , object parameters , CancellationToken token = default ) { await using var connection = connectionInfo . GetConnection < T > ( ) ; var result = await connection . ExecuteScalarAsync ( sql , parameters , cancellationToken : token ) . ConfigureAwait ( false ) ; return result != null ? new SaveResult < TKey > ( ( TKey ) result , true ) : new SaveResult < TKey > ( ( TKey ) DefaultSqlId < TKey > ( ) ) ; }
Execute sql command to save an entry.
Execute sql command to save an entry .
None
connectionInfo
IConnectionInfo
None
sql
string
None
parameters
object
None
token
CancellationToken
None
typeparam
None