robconery/massive — pull request #137 by DoggettCK (2012-04-03 15:58:56+00:00)
Title: Added DbConnectionStringBuilder constructors

I absolutely love Massive. I have to deal with a bunch of Access MDB files that get uploaded to a shared directory, and it's too much of a pain to constantly update my app.config with new connection strings, so I've added a new constructor that takes a System.Data.Common.DbConnectionStringBuilder, which I can build on the fly from filenames or other properties.

Assuming you have the correct drivers, you can use any of the following:

System.Data.EntityClient.EntityConnectionStringBuilder
System.Data.Odbc.OdbcConnectionStringBuilder
System.Data.OleDb.OleDbConnectionStringBuilder
System.Data.OracleClient.OracleConnectionStringBuilder
System.Data.SqlClient.SqlConnectionStringBuilder

Example:

foreach (string filename in Directory.EnumerateFiles(dataDirectory, "*.mdb"))
{
var accessBuilder = new OleDbConnectionStringBuilder
{
Provider = "Microsoft.Jet.OLEDB.4.0",
DataSource = filename
};

accessBuilder["ProviderName"] = "System.Data.OleDb";

var patientExtract = new PatientExtract(accessBuilder);
Console.WriteLine("Patient Count: {0}\tFile: {1}", patientExtract.Count(), filename);
}