Note that there are some explanatory texts on larger screens.

plurals
  1. POProper way to transform column and table names in SubSonic 3
    text
    copied!<p>I am attempting to transform a table named <code>app_user</code> which has a column named <code>created_dt</code> 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</p> <p>So I added this method to Settings.ttinclude</p> <pre><code>string UnderscoreToCamelCase(string input) { if( !input.Contains("_")) return input; StringBuilder sb = new StringBuilder(); for (int i = 0; i &lt; input.Length; i++) { if (input[i] == '_') { while (i &lt; input.Length &amp;&amp; input[i] == '_') i++; if (i &lt; 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(); } </code></pre> <p>And then this call to CleanUp</p> <pre><code>result=UnderscoreToCamelCase(result); </code></pre> <p>If I run a query such as :</p> <pre><code>var count = (from u in AppUser.All() where u.CreatedDt &gt;= DateTime.Parse("1/1/2009 0:0:0") select u).Count(); </code></pre> <p>I get a NotSupportedException, The member 'CreatedDt' is not supported</p> <p>which comes from a method in TSqlFormatter.sql line 152</p> <pre><code>protected override Expression VisitMemberAccess(MemberExpression m) </code></pre> <p>If I comment out the call to UnderscoreToCamelCase and use the names as they are in the database everything works fine.</p> <p><strong>One interesting thing is that when everything is working OK the VisitMemberAccess method is never called.</strong></p> <p>Has anyone else been able to convert table/column names with undersores in them to camel case in SubSonic3 ?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload