/// <summary>
 /// 异步执行没有结果的查询
 /// </summary>
 /// <param name="query">要执行的查询对象</param>
 /// <param name="token">取消指示</param>
 /// <returns>查询所影响的行数</returns>
 public static async Task <int> ExecuteNonQueryAsync(this IDbExecutableQuery query, CancellationToken token = default(CancellationToken))
 {
     using (var context = await query.ExecuteAsync(token))
     {
         return(context.DataReader.RecordsAffected);
     }
 }
        /// <summary>
        /// 异步执行查询并将第一个结果集包装成 DataTable 返回
        /// </summary>
        /// <param name="query">要执行的查询对象</param>
        /// <param name="token">取消指示</param>
        /// <returns>查询结果</returns>
        public static async Task <DataTable> ExecuteDataTableAsync(this IDbExecutableQuery query, CancellationToken token = default(CancellationToken))
        {
            using (var context = await query.ExecuteAsync(token))
            {
                var data = new DataTable();
                data.Load(context.DataReader);

                return(data);
            }
        }
        /// <summary>
        /// 异步执行查询并返回首行首列
        /// </summary>
        /// <param name="query">要执行的查询对象</param>
        /// <param name="token">取消指示</param>
        /// <returns>查询结果</returns>
        public static async Task <object> ExecuteScalarAsync(this IDbExecutableQuery query, CancellationToken token = default(CancellationToken))
        {
            using (var context = await query.ExecuteAsync(token))
            {
                if (context.DataReader.Read())
                {
                    return(context.DataReader[0]);
                }

                else
                {
                    return(null);
                }
            }
        }
        /// <summary>
        /// 异步执行查询并将所有结果集包装成 DataTable 返回
        /// </summary>
        /// <param name="query">要执行的查询对象</param>
        /// <param name="token">取消指示</param>
        /// <returns>查询结果</returns>
        public static async Task <DataTable[]> ExecuteAllDataTablesAsync(this IDbExecutableQuery query, CancellationToken token = default(CancellationToken))
        {
            List <DataTable> dataTables = new List <DataTable>();

            using (var context = await query.ExecuteAsync(token))
            {
                do
                {
                    var data = new DataTable();
                    data.Load(context.DataReader);

                    dataTables.Add(data);
                } while (context.DataReader.NextResult());
            }

            return(dataTables.ToArray());
        }