by Digvijay
23. July 2009 01:05
I went back to SubSonic website just to check what is new and I was happy to see the 3.0 release. Just downloaded and started to play around with it. Also, this week while i was reading again my favorite book on Data Binding - "Data binding with Windows Forms 2.0" by Brian Noyce I thought I can just try the code I am writing with new shiney SubSonic 3.0!
ActiveRecord looks nice but i was thrilled to see the SimpleRepository Screencast and could not help writing a small application using it. It is quite flexible as far as selecting a Database is concerned. I have used SubSonic 2.x earlier and i liked it, after playing around for a couple of hours i felt what would i do without it.
And as Rob Conery said “A SimpleRepository which is just about zero-drag and even builds your database for you” and i was amazed to see it really does all that is promised!. Though the release has a few bugs when i was writing my demo application but i could see on GitHub other people discussing those bugs and proposing fixes.
Here you can download the demo application i wrote which shows some data binding concepts and how to go about using SubSonic SimpleRepository in a Forms application. Hope you find it informative.
But as Rob discussed in another post if SubSonic is a toy or a tool for serious development i would say i did use SubSonic 2.x in more than 4 projects which are in production now and I had far less bug reports where data access is concerned. And i hope to do better with SubSonic 3.x.
Let use see what comes next :)
by Digvijay
31. October 2008 05:30
SubSonic is a great tool and makes it really easy to work with data access and is easy to configure as well. But a major problem that I faced was moving from development to production and then non technical people sometimes have to open and modify the *.config file all the time to change the configuration for subsonic service section in the web.config or app.config. And the support becomes a nightmare for this trivial thing.
Interestingly, there is a way around it that i discovered a few days back. Here is the code snippet to do that:
private static bool _bIsInitialized = false;
private void InitSubsonic()
{
if (_bIsInitialized)
return;
DataService.Providers = new DataProviderCollection();
// here you can get settings from anywhere and make up a connection string :)
CustomDataProvider provider = new CustomDataProvider("Data Source=(local); Database="WebShop"));
DataService.Providers.Add(provider);
DataService.Provider = provider;
_bIsInitialized = true;
}
// Here it is MySql that i needed but you
// may have any provider supported by SubSonic
private class CustomDataProvider : MySqlDataProvider
{
public CustomDataProvider(string connectionString)
{
DefaultConnectionString = connectionString;
}
public override string Name
{
get
{
return "WebShop"; // Database Name does not change often!!
}
}
}
And i just called the InitSubsonic method in the Form_Load event handler (it was a windows app). And it just worked!!!
I hope a few developers find this trick useful!!!