Am I expecting too much ?
[*** Rant Warning : Level 5 ***]
Alot of awsome blogging has been happening around new microsoft technologies, and it seems like a demo or tutorial is sprouting under every tree. And just as you got convinced to try and use this new-cool-automatic-freshness, you get into your first wtf within 5minutes.
And the driving force of this blog post : LinqDataSource. Brand-spankin'-new with all the bells and whistles. Just set it up, point it to your DataContext type name, connect it to your GridView or whatever, and voila.
But hey - I want to use a connection string from the CONFIGURATION file, and _NOT_ leave it hardcoded, running around like a rabid dog in my assembly.
So, the average programmer starts typing -
myDataSource.Conn.... Hey - Where's the ConnectionString property? ConnectionStringName? Hellloooooo... Anybody there? oh crap. they got me yet again.
Turns out Google is swamped by unfortunate bums like me trying to figure out what's going on. Out of 5 blogs/forum posts I bothered reading, 1 had a semi-proper solution, and the other four CONCLUDED the forum discussion with "LinqDataSource does not support setting the connection string at runtime."
There are several solutions, from reflection (for the psychos), extending the context with a new default constructor in a partial class (deleting the old one), or just deriving from your old DataContext with a new AutoConfiguredDataContext:MyDataContext, setting the default constructor as the one which goes to configuration to fetch the connString.
Code will be posted on demand.
My point is different - Why is this option buried behind a semi-brick wall ?
Out of all the code in the BCL, Grids and DataSources have some of the most lengthy class sources, and the ConnectionString property is what put the project at risk ?
What was the motivation behind this - force everyone to create designer-only apps ?
Please, anyone with a half-decent reasoning for this, gets cudos from me. Really - hats off.