Proper way to transform column and table names in SubSonic 3

subsonicsubsonic3

I am attempting to transform a table named app_user which has a column named created_dt into AppUser.CreatedDt in SubSonic3 using the ActiveRecord template. From what I've seen one should be able to modify table and column names as needed in the CleanUp method of Settings.ttinclude

So I added this method to Settings.ttinclude

string UnderscoreToCamelCase(string input)  {

        if( !input.Contains("_"))
            return input;

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < input.Length; i++)
        {
            if (input[i] == '_')
            {
                while (i < input.Length && input[i] == '_')
                    i++;
                if (i < input.Length)
                    sb.Append(input[i].ToString().ToUpper());
            }
            else
            {
                if (sb.Length == 0)
                    sb.Append(input[i].ToString().ToUpper());
                else
                    sb.Append(input[i]);
            }
        }

        return sb.ToString();
    }

And then this call to CleanUp

result=UnderscoreToCamelCase(result);

If I run a query such as :

var count = (from u in AppUser.All()
             where u.CreatedDt >= DateTime.Parse("1/1/2009 0:0:0")
             select u).Count();

I get a NotSupportedException, The member 'CreatedDt' is not supported

which comes from a method in TSqlFormatter.sql line 152

protected override Expression VisitMemberAccess(MemberExpression m)

If I comment out the call to UnderscoreToCamelCase and use the names as they are in the database everything works fine.

One interesting thing is that when everything is working OK the VisitMemberAccess method is never called.

Has anyone else been able to convert table/column names with undersores in them to camel case in SubSonic3 ?

Best Answer

There may be an answer to this on another thread within StackOverflow, but it entails modifying the source code for Subsonic.core. link text