T4 Templates and connection strings in a class library

I'm using the template posted in this thread to generate C# enums from a couple of lookup tables in SQL Server within a class library that contains my DAL.

At the moment, I have the connection string used by the templates embedded an a template include file in the class library. Is there a convenient way to have the template grab the connection string from the main project (WAP)'s web.config without having to include a physical path? Or is there a better way to approach this?

Edit

I've also considered creating a SQL CLR assembly which returns a table-valued function containing the enum contents (which would then be defined in C#, not in the database), but I'm not sure what the performance hit would be. Whether or not it's significant will obviously be application-dependent but I'd hate to charge down a crappy path if it's a know best-avoid-this approach.

7
задан Community 23 May 2017 в 09:58
поделиться