A seamless transition from Linq to Subsonic

We definitely have better things to do than worry about and invest more time on DataAccess … if that’s what you too had in mind… then for sure you would try to use a DataAccess tool .. a sort of layering which provides us more easy way of accessing Data than worrying about the Data Structure and SQL ….
Somehow after using LINQ for quite a long time, when I was exposed to a LINQ powered Super High-fidelity Batman Utility Belt ( as they say), the SUBSONIC , I had my own hundreds reasons for not trying it out .. Sitting in the comfort zone of LINQ (though many times a little draggy and time consuming), I still had a sort of first hand aversion to start off …
But a time came when I was in a bad constraint of time….along with constant changes in the DB design that I really felt.. Subsonic is a better choice… and if you are not new to LINQ, this one would be like a feather for you.. .both for ease and speed…
Check out their short demo here on how to include it in your project. There is a slight difference in Website & Web application which you can easily do viewing the screen cast.
Nevertheless, it works like charm!  And coding wise, it’s absolutely simple…
You too should check this one out! Subsonic is all about helping you do what you need to do with the least amount of friction…
For a Website, the following are the steps of including the SUBSONIC.
a)    Download Subsonic  here
b)    Include the subsonic.dll into your bin directory.
c)    Add the following section into your web.config

Inside the configurations, add a new section:

<section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" requirePermission="false"/>

Under Appsettings add:

<SubSonicService defaultProvider="MainMs">
		<providers>
			<clear/>
			<!--CMS Provider-->
			<add name="MainMs" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="dbConnectionString" generatedNamespace="subsonicDB"/>
		</providers>
	</SubSonicService>

Here connectionstring ‘dbConnectionString’ refers to a correct connection string in the same web.config

Under compilation tag, add

<buildProviders>
	<add extension=".abp" type="SubSonic.BuildProvider, SubSonic"/>
</buildProviders>

Create a file with a suitable name and ‘.abp’ extension. The name does not matter at all here, only the extension does. Just add ‘*’ as its content. It would be a 1kb file. Place it in your business logic folder if you have one.

Build the website project, the namespace ‘GENSUB’ or any unique name of your choice, would start mapping to your Database to which you have pointed in the web.config.

In order to access the database values, we could use:

iCountryId = 24;
subsonicDB.Country country = new subsonicDB.Country (iCountryId);

would give Country object with values populated for the country with primary key 24.

* Drawbacks:
This particular tool is a brainchild of a single person , and is not a heavily branded and marketed name in the industry. Still you would find a whole lot of people mainly who are inclined towards open source using it in its full strength.
Couple it with the free open source .Net CMS, Umbraco, it works absolutely brilliant. 🙂

Advertisements

About mytechlifedays

Its been a wonderful learning period over the last 6 years in the IT industry , getting exposed to whole lot of technologies and ideas. The hurdles and the crisis that came along have been wonderful experience ... And now its time to pen them down so that let some others execute faster and easily with these information .....
This entry was posted in .Net and tagged , , , . Bookmark the permalink.

Leave a Reply ! It would be always appreciated ! :)

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s