Tao Te KaChing
Workin' the cash register of the Great Tao

SubSonic, Enums, and Me...

So, I have been using SubSonic on a project, and love it.  It is absolutely a fantastic quick-data-access-layer solution, and far, far easier to use than CodeSmith + netTiers.  However, one limitation that the CodeSmith + netTiers solution provided, which was very nice to have, are auto-generated enums from enum tables.

I threw something together here which does the job.  I have my DAL generated by SubSonic in its own project, then have this run post-build, then ILMerge, to create a “final” DAL assembly that contains current table enums in it.

Basically, the strategy was simple: use a config file to specify the tables and their respective PK and “descriptor” columns, and then let System.Reflection.Emit build an assembly containing the enums.

The code for this is available here.  Two projects are included: the EnumEmitter console app to generate the enum assembly, and Sandbox, which is really a blank console app referencing a sample enum assembly built from the AdventureWorks


Any ideas on improvements and / or features, let me know and I’ll get them in there.