SubSonic 3.0 – Is it a Toy?

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 :)

Tags:

.NET | DAL and Code Generation | SubSonic

SubSonic Trick : Specify connection string at runtime!

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!!!

Tags:

DAL and Code Generation | SubSonic

 

About Digvijay

  Digvijay Chauhan
I am a developer living in Stockholm, Sweden and I love to program and work on cutting edge technologies in the Microsoft Technology space.

LinkedIn Twitter StackOverflow

Certifications

Digvijay Chauhan Microsoft Certification Logo

Other Pages

RecentPosts

Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar

Most comments

Live Traffic

Live Traffic Feed
  Västra Frölunda, Vastra Gotaland arrived from digvijay.eu on "blank_page"

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

Translate