I am converting a WCF service with a SQL Server backend to PostgreSQL. I am using [`Npgsql`](http://npgsql.projects.pgfoundry.org/) but it does not have a bulk copy option. **test** is the dataset here.

This is my sql code,

```
        DataSet ds = DuobaseHandler.ToDataSet(test);
        DataTable dt = ds.Tables[0];
        string TableNameOrig = "CDA." + TableName;
        DataTable dataTable = dt; 
        try
        {
            ConnectionStringSettings mConString = ConfigurationManager.ConnectionStrings["CommonDataConnection"];
            string[] columnNames = dt.Columns.Cast<System.Data.DataColumn>()
                     .Select(x => x.ColumnName)
                     .ToArray();
            string[] ColumnsFinal = columnNames.Take(columnNames.Count() - 2).ToArray();
            using (SqlConnection ConnectionSQL = new SqlConnection(mConString.ConnectionString))
            {
                ConnectionSQL.Open();
                // Delete old entries
                SqlCommand truncate = new SqlCommand("TRUNCATE TABLE" + " " + "CDA." + TableName, ConnectionSQL);
                truncate.ExecuteNonQuery();

            }
            SqlBulkCopy bulkCopy = new SqlBulkCopy(mConString.ConnectionString, SqlBulkCopyOptions.TableLock)
            {
                DestinationTableName = TableNameOrig,
                BatchSize = 100000,
                BulkCopyTimeout = 360
            };
            foreach (var item in ColumnsFinal)
            {
                bulkCopy.ColumnMappings.Add(item.ToString(), item.ToString());
            }

            bulkCopy.WriteToServer(dataTable);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
        }
        return true;

```