1.) Add the SubSonic.dll reference, which can usually be found in: C:\Program Files\SubSonic\SubSonic 2.0.3\SubSonic.dll
a.) Project->Add Reference
b.) Browse tab and go to the path above
2.) Add the System.Web and System.configuration references. Even though this is a WinForm you *MUST* have System.Web or else you will get compile errors demanding such. Same thing with System.Configuration.
a.) Project->Add Reference
b.) Scroll down to add these, they are usually near the bottom
3.) Create an App.config file. Anything in caps and surrounded by % is something you need to fill out yourself.
NAME_X is a name given to name the connection string.
NAME_Y is the name you will refer to it from within your project.
SERVER_NAME -- Self explanatory
DBNAME -- Self explanator
Here is an example layout with the above variables which you need to replace with appropriate values:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" requirePermission="false" />
</configSections>
<appSettings/>
<connectionStrings>
<clear />
<add name="%NAME_X%" connectionString="Data Source=%SERVER_NAME%; Database=%DBNAME%; Integrated Security=true;" />
</connectionStrings>
<SubSonicService defaultProvider="%NAME_X%">
<providers>
<clear/>
<add name="%NAME_X%" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="%NAME_X%" generatedNamespace="%NAME_Y%"/>
</providers>
</SubSonicService>
</configuration>
4.) Generate your SubSonic DAL (Data Access Layer). If you already have your Studio setup such that you clickety the button, skip this step. This step will walk you through configuring this.
a.) Go to Tools->External Tools
b.) Click 'Add' and feed it the following information
1.) Title: &SubSonic DAL
2.) Command (Your exe file may be located in a different location): C:\Program Files\SubSonic\SubSonic 2.0.3\SubCommander\sonic.exe
3.) Arguments: generate /out Generated
4.) Prompt for arguments: Check this box (not required, but useful).
5.) click OK.
c.) If you want to have a handy button on your project, instead of having to go through the Tools menu then do the following.
1.) We need to determine which tool this is, so count down starting at 'Macros' (assuming Macros is '0'), usually the value is 3. Which means your menu might look like:
'Macros' -- 0
'Create GUID' -- 1
'DotFuscator Community Edition' -- 2
'SubSonic DAL' -- 3
So we'll save this number (3) for later.
2.) Go to Tools->Customize
3.) Go to the 'Toolbars' tab.
4.) Click 'New'.
5.) Name it whatever, but I suggest 'SubSonic' -- in case you want to add more tools from them later. Keeping it generic is good.
6.) Go to the 'Commands' tab.
7.) Scroll down to 'Tools' in the left side.
7.) In the right side, scroll down to 'External Command X' Where X is the number we saved on the first step.
5.) Create a directory in your the room of your project (where your code is) called 'Generated'. 6.) Click the button you created to generate the SubSonic DAL code. 7.) Right-click on the 'Generated' directory and select 'Add'->'Existing Item' and go to the 'Generated' directory. Select everything and add it. 8.) Smile. Your project should have SubSonic integrated now.
