views:

169

answers:

1

I have an issue when the T4 linq templates generate the classes for my MySql db using subsonic 3.

It looks like one of our table names "operator" is causing problems in the Context.cs generated class. In the following line of code in Context.cs Visual Studio sees <operator> as a c# operator and generates a compilation error of "Type expected"

public Query<operator> operators { get; set; }

Is there anyway I can work around this without having to rename my database table and column names? For example hard coding something in Settings.ttinclude to use or map different names to specific db tables and columns?

+2  A: 

The CleanUp() function was built for this - it's in Settings.tt. You should be able to rename your class as needed.

Rob Conery
Thanks Rob. I added an if statement to the CleanUp() function like so://put your logic here... if (tableName.Equals("providers")) result = "providersTable";in the hope that the tableName "providersTable" would be used as apposed to "provider". No joy though.. is there something else I should be doing? is CleanUp() called automatically during the generation of the template classes?
craig
Found a good example in the comments on this page http://blog.wekeroad.com/subsonic/subsonic-3-0-preview-2/of additions to teh CleanUp() function and the Settings.ttinclude. Search the page for bbqchickenrobot's comments.
craig