I've run into a problem when using SubSonic 3(.0.0.3) ActiveRecord with MySQL.
Since MySQL doesn't allow you to use uppercase letters in table or column names (or rather disregards it if you do) I decided to separate words using underscores, e.g. entity_id, and then use the CleanUp() method to add title casing and remove the underscores.
A friend wrote a ToTitleCase(string s) method that looks like this:
string ToTitleCase(string s)
{
CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
TextInfo textInfo = cultureInfo.TextInfo;
return textInfo.ToTitleCase(s);
}
And the CleanUp() method looks like this:
string CleanUp(string tableName){
string result=tableName;
//strip blanks
result=result.Replace(" ","");
//put your logic here...
result = ToTitleCase(result);
result = result.Replace("_", "");
return result;
}
If I then do:
var entity = Entity.All().Where(e => e.EntityName.Contains("John"));
I get a NotSupportedException, with the message "The member 'EntityName' is not supported."
If I remove
result = result.Replace("_", "");
Everything works just fine, only I get properties looking like Entity_Id which is not quite what I want.
If anyone knows why this happen, I would love to hear it. If it's possible to fix, even better! It's no showstopper but it's slightly annoying.