/// <summary>
        /// Bulk insert data reader synchronously. If using sql server, use SqlServer extension methods instead.
        /// </summary>
        /// <param name="dataReader"></param>
        /// <param name="connection"></param>
        /// <param name="destinationTableName"></param>
        /// <param name="databaseEngine"></param>
        /// <param name="bulkInsertOptions"></param>
        public static async Task BulkInsertUsingInsertStatements(
            this IDataReader dataReader,
            DbConnection connection,
            string destinationTableName,
            DatabaseEngine databaseEngine,
            GenericBulkCopyOptions bulkInsertOptions = null)
        {
            var bulkCopy = GetBulkCopy(destinationTableName, connection, bulkInsertOptions);

            await bulkCopy.WriteToServer(dataReader, destinationTableName, databaseEngine);
        }
        /// <summary>
        /// Data table version.
        /// </summary>
        /// <param name="destinationTableName"></param>
        /// <param name="connection"></param>
        /// <param name="sqlServerBulkInsertOptions"></param>
        /// <returns></returns>
        private static GenericBulkCopy GetBulkCopy(
            string destinationTableName,
            DbConnection connection,
            GenericBulkCopyOptions sqlServerBulkInsertOptions = null)
        {
            sqlServerBulkInsertOptions = sqlServerBulkInsertOptions ?? new GenericBulkCopyOptions();

            var bulkCopy = new GenericBulkCopy(connection, sqlServerBulkInsertOptions);

            return(bulkCopy);
        }
        //TODO: needs to support mapping columns

        /// <summary>
        /// Bulk upload enumerable by generating insert statements. If using sql server, use SqlServer extension methods instead.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="items"></param>
        /// <param name="dbConnection"></param>
        /// <param name="destinationTable"></param>
        /// <param name="databaseEngine"></param>
        /// <param name="bulkInsertOptions"></param>
        public static async Task BulkInsertUsingInsertStatements <T>(
            this IEnumerable <T> items,
            DbConnection dbConnection,
            string destinationTable,
            DatabaseEngine databaseEngine,
            GenericBulkCopyOptions bulkInsertOptions = null)
        {
            var d = new GenericBulkCopy(dbConnection, bulkInsertOptions);

            await d.WriteToServer(items.ToDataReader(), destinationTable, databaseEngine);
        }
 /// <summary>
 /// Initializes a new instance of the SqliteBulkCopy class using the specified open instance of SqliteConnection.
 /// </summary>
 /// <param name="connection"></param>
 /// <param name="bulkCopyOptions"></param>
 public GenericBulkCopy(DbConnection connection, GenericBulkCopyOptions bulkCopyOptions = null)
 {
     BulkCopyOptions = bulkCopyOptions ?? new GenericBulkCopyOptions();
     Connection      = connection;
 }