About

SubSonic is a .net open source project developed by Rob Conery and a core team of developers including Eric Kemp, Scott Watermasysk, Jon Galloway, Phil Haack, and Gavin Joyce. The current stable release is version 2.0.3. Nightly builds are available in our SVN respository.

Tags

Defining Which Tables And Views You Want To Generate Code For

Many times you don't want to generate code for particular tables or views in your database (the aspnet_* tables, for instance), or you don't want the table's name to carry through as it is. We've tried to make this easy for you to deal with by use of Regex and naming rules that you can set on the Provider.

 

includeTableList and excludeTableList

You can set these flags on the Provider, and they will determine which tables get generated for you. They use Regex for matching so you can even specify wildcards.

If we're using Northwind and I only want to generate objects for Product and Category, I can by defining this way:

<add name="Northwind" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="Northwind" 
generatedNamespace="Northwind" includeTableList="Product,Category"/>

If I've added tables to the database (let's pretend they are CMS tables) and prefixed them with "CMS", I can add those as well using Regex:

<add name="Northwind" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="Northwind" 
generatedNamespace="Northwind" includeTableList="Product,Category,CMS_*"/>

excludeTableList works just the same, but excludes the tables/patterns you specify.

 

Altering Table Names
You can alter the way we generate the class names for your tables pretty easily. For more on these see our writeup on naming issues.

Subscribe