コード例 #1
0
        /// <summary>
        /// Executes the command, returning the first column of the first result, converted to the type T asynchronously.
        /// This method is only supported if the underlying provider propertly implements async behaviour.
        /// </summary>
        /// <typeparam name="T">return type</typeparam>
        public async Task <T> AsScalarAsync <T>()
        {
            var result = await ExecuteAsync.Scalar();

            return(ConvertTo <T> .From(result));
        }
コード例 #2
0
 /// <summary>
 /// Get a value from an IDataRecord by index. This method supports all types,
 /// as long as the DbType is convertible to the CLR Type passed as a generic argument.
 /// Also handles conversion from DbNull to null, including nullable types.
 /// </summary>
 public static TResult Get <TResult>(this IDataRecord reader, int c) => ConvertTo <TResult> .From(reader[c]);
コード例 #3
0
 /// <summary>
 /// Executes the command, returning the first column of the first result, converted to the type T
 /// </summary>
 /// <typeparam name="T">return type</typeparam>
 public T AsScalar <T>() => ConvertTo <T> .From(AsScalar());