minhphien / migratordotnet

Automatically exported from code.google.com/p/migratordotnet
0 stars 0 forks source link

I can't get access to the connection or connection string #167

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Write a migration
2. Try to get accesss to the connection
3. Try again. 
4. Still nothing. 

What is the expected output? What do you see instead?
I would expect two properties
Database.Connection
Database.ConnectionString

What version of the product are you using? On what operating system? With what 
.NET implementation/version?
The latest of everything :)

What database and version are you seeing this issue on?
All of them would be the same, but I'm using MSSQL

Please provide any additional information below.
A workaround is to use reflection and get the private fields
var field = Database.GetType().GetField("_connectionString", 
BindingFlags.NonPublic | BindingFlags.Instance);
var connection = field.GetValue(Database) as string;

or I could also create a command just to have access to this
Database.GetCommand().Connection.ConnectionString;

That's more like a hack than a real solution. 

BTW, in this case I need them because I want to add some data using NHibernate. 

Original issue reported on code.google.com by ICantFin...@gmail.com on 27 Jan 2011 at 2:55