views:

21

answers:

1

What I want to achieve is more or less the inverse of this:

http://www.olegsych.com/2008/07/t4-template-for-generating-sql-view-from-csharp-enumeration/

I have a value group table (enum names) and a values table (enum values), and want to turn those into enums. Both are in SQL Server, and both do happen to be in an .edmx (so there would be quite a few ways to read the values).

Is there something "out there" that already does this (and I didn't find it)? If not, what would be the best way to go about reading the data (SMO, EDMX with dynamic loading, ...)

A: 

Ok, here's how I implemented it:

  • Use VolatileAssembly from the T4 Toolbox to reference an assembly that...
  • Implements a T4 Helper class that does all the database work (when using EF, make sure to use a connection string when instantiating the context)
  • In the .tt, simply call into the T4 helper class to get the data you need and create your class(es)
Christoph Wille