Configure SubSonic for a Windows application and sort out the table names
Web or Windows applications?
SubSonic was originally developed to aid in the creation of web applications, but with a bit of tweaking it is also possible to use it for Windows or console applications. When you generate your DAL using the Sonic.exe tool, it is looking for a web.config file in your project root. Add this config file with your usual settings like in my previous post and generation will work fine. However when running the application you need the same config file, but renamed to match your application.exe name such as application.exe.config. I don't quite know why this has to be done, but it works for me and I have never looked in to a better way of doing it. Also if like me you use a NAnt script, then you can copy and rename your original web.config to this application.exe.config everytime you perform a build.
Those darn table names...
Ok you have SubSonic set up and you have generated a DAL for your database, but wait on you don't want all the tables in your database. You can filter your choice of tables by using the includeTableList attribute in your web.config. Also if you find your tables have crappy names which don't mean anything when you come to use your DAL in your application, you can use the regexReplaceExpression to swap these with more meaningful names.
1: <SubSonicService defaultProvider="providername">
2: <providers>
3: <clear/>
4: <add name="providername"
5: type="SubSonic.SqlDataProvider, SubSonic"
6: connectionStringName="connectionname"
7: generatedNamespace="yournamespace"
8: includeTableList="table1, table2, table3"
9: regexDictionaryReplace="table1,Accounts;table2,Customers;table3,Products"/>
10: </providers>
11: </SubSonicService>