Monday, December 31, 2007

Sub Sub

No this title does not refer to the band which then became Doves. No just recently I have been getting to grips with Subversion and Subsonic (I could have gone for Subtext on our latest project but went for BlogEngine.Net then we would have Sub Sub Sub)

Subversion
You may remember a post back in May when I started to use Source Safe 2005. Everything was working fine until one day it decided to rearrange my directory structure for a web application I was working on. I sorted it out and a while later it happened again. I decided to look around for an alternative to Source Safe and soon came across Subversion. My intention was to use Subversion for web applications while keeping all my other code in Source Safe for the time being. This was mainly because I really didn't want my code just sitting around outside any form of source control. Subversion just does what I want it to do; controlling my source without guessing what I want to do with it which is what Source Safe seemed to do. Setting up Subversion was a breeze, there is so much help on the web. My main sources where:-

Step-by-Step instructions for running a Subversion repository under Windows

This got me up and running with Subversion, the Subversion service and TortoiseSVN. I wanted to integrate with VS2005 so I installed AnkSVN. Everything was running swimmingly until I realised that the repository would be better on a different drive to where I put it (on the C drive stupidly, but this was to be a temp location until we get the final location upgraded to 2003 Server). So using this source, I successfully moved it. I have had it up and running now for about 4 months with no problems. Gradually I have slowly moved my source code over from SS2005 with an intention to ditch it in the new year.

Incase you need any more links for Subversion goodies, these are what I found to be really useful:-

Subversion Part 1 - Installing Subversion as your code repository for Windows users

Subversion & TortoiseSVN: Installed and started on Windows 2003 server and local machines

Software Carpentry - Version Control with Subversion

This last post contains links to video tutorials covering different aspects of Subversion.

Subsonic

The next Sub is Subsonic. An ORM which just works. I cannot believe how simple this was to set up. As this is something I will probably need in the future I will document the process here, who knows someone may find it useful.

1. Download it from CodePlex and run the exe.

2. Once it has installed create a link to the command in Visual Studio by going to Tools>>External Tools>>Add

Tools

This will generate the code for the DAL based on your settings in the web.config file.

3. Speaking of which here is a sample of the important parts of my web.config

<configSections>
<section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" requirePermission="false" />
<connectionStrings>
<add name="connectionname" connectionString="Data Source=servername; Database=databasename; Integrated Security=true;" />
</connectionStrings>
<SubSonicService defaultProvider="providername">
<providers>
<clear/>
<add name="providername" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="connectionname" generatedNamespace="yournamespace"/>
</providers>
</SubSonicService>
</configuration>

Just swap out connectionname, databasename, providername and yournamespace with your values.

4. Now the fun bit. Run Tools>>SubSonic. This will automatically generate the code for your ORM classes in a directory called Generated within your VS project. That is all you need to get up and running. I will post some simple code examples in the new year.


Here are some links I found useful:-


Getting started with SubSonic
For Web Sites - Using the BuildProvider
Video on getting started with SubSonic
Setting up SubSonic


Well enjoy the rest of the holiday and I will get back to blogging in the new year...erm well tomorrow then.