Invalid Token 'event' in class...error compiling SubSonic project
I'm just fooling around with the subsonic ORM for the first time. I'm using the ActiveRecord templates
I've edited the include files as per the instructions on the subsonic web site and pointed the app.config file to my MySql database.
When I go to compile the class library I get the following error
Invalid token 'event' in class, struct, or interface member declaration
I'm guessing the problem is due to the fact that one of my Tables is named "Events" and Subsonic must take that, chop off the "S" and end up generating code that trys to create a type named "event" which creates problems because event i开发者_Go百科s a keyword in C#.
Am I right about this? And is there a way around it without renaming tables in my database?
EDIT:
The error is generated in the context.cs file on the following line
public Query<event> events { get; set; }
Look at the top of your Settings.ttinclude
file.
There is a CleanUp method that you can use to modify your table names.
I don't know if that fires, before or after the "s" get's chopped of but one or the other way you can append an additional "s" to force the class name to be events
rather than event
or you can even rename the table to something totally different
string CleanUp(string tableName){
string result=tableName;
//strip blanks
result=result.Replace(" ","");
//put your logic here...
if (result.ToLower() == "event")
result = result + "s";
else if (result.ToLower() == "events")
result = result + "s";
// or
if (result.ToLower() == "event")
result = "somethingthathappensonaspecificdate"; // ;-)
return result;
}
精彩评论