Data/CafeLib.Data.Sources/SqlCommandProvider.cs
/// <summary>
/// Query count based on the entity key.
/// </summary>
/// <typeparam name="TEntity">Entity type</typeparam>
/// <typeparam name="TKey">Key type</typeparam>
/// <param name="connectionInfo">Connection info</param>
/// <param name="key">entity key</param>
/// <param name="token">Cancellation token</param>
/// <returns>Query result</returns>
Query count based on the entity key.
Query count based on the entity key .
public async Task<int> QueryCountAsync<TEntity, TKey>(IConnectionInfo connectionInfo, TKey key, CancellationToken token = default) where TEntity : class, IEntity
        {
            var keyColumnName = PrimaryCache.Get<TEntity>().GetMappedName();
            var tableName = ClassMappedNameCache.Get<TEntity>();
            var result = await ExecuteAsync(connectionInfo, $@"SELECT TOP 1 {keyColumnName} FROM {tableName} WHERE {keyColumnName} = {CheckSqlKey(key)}", null, token).ConfigureAwait(false);
            return result;
        }
public async Task < int > QueryCountAsync < TEntity , TKey > ( IConnectionInfo connectionInfo , TKey key , CancellationToken token = default ) where TEntity : class , IEntity { var keyColumnName = PrimaryCache . Get < TEntity > ( ) . GetMappedName ( ) ; var tableName = ClassMappedNameCache . Get < TEntity > ( ) ; var result = await ExecuteAsync ( connectionInfo , $@" SELECT TOP 1  { keyColumnName }  FROM  { tableName }  WHERE  { keyColumnName }  =  { CheckSqlKey ( key ) } " , null , token ) . ConfigureAwait ( false ) ; return result ; }
Query count based on the entity key.
Query count based on the entity key .
None
connectionInfo
IConnectionInfo
None
key
TKey
None
token
CancellationToken
None
typeparam
None
typeparam
None