Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For many many months this was an issue for me and I just avoided underscores when working with SubSonic on any supported DB. Until yesterday when I had to support a legacy project that had underscores in its SQL Server database. </p> <p>You'll have to fix it within the source code of SubSonic.Core (file: SubSonic.Core\Schema\DatabaseTable.cs):</p> <p>Find this method:</p> <pre><code>public IColumn GetColumnByPropertyName(string PropertyName) { return Columns.SingleOrDefault(x =&gt; x.Name.Equals(PropertyName, StringComparison.InvariantCultureIgnoreCase)); } </code></pre> <p>And change it to:</p> <pre><code>public IColumn GetColumnByPropertyName(string PropertyName) { return Columns.SingleOrDefault(x =&gt; x.PropertyName.Equals(PropertyName, StringComparison.InvariantCultureIgnoreCase)); } </code></pre> <p>Next you'll have to modify your <strong>Structs.tt</strong>:</p> <p>Find this near the top:</p> <pre><code>Columns.Add(new DatabaseColumn("&lt;#=col.Name#&gt;", this) { IsPrimaryKey = &lt;#=col.IsPK.ToString().ToLower()#&gt;, DataType = DbType.&lt;#=col.DbType.ToString()#&gt;, IsNullable = &lt;#=col.IsNullable.ToString().ToLower()#&gt;, AutoIncrement = &lt;#=col.AutoIncrement.ToString().ToLower()#&gt;, IsForeignKey = &lt;#=col.IsForeignKey.ToString().ToLower()#&gt;, MaxLength = &lt;#=col.MaxLength#&gt; }); </code></pre> <p>And add this line:</p> <pre><code> PropertyName = "&lt;#=col.CleanName#&gt;", </code></pre> <p>So that it becomes:</p> <pre><code>Columns.Add(new DatabaseColumn("&lt;#=col.Name#&gt;", this) { PropertyName = "&lt;#=col.CleanName#&gt;", IsPrimaryKey = &lt;#=col.IsPK.ToString().ToLower()#&gt;, DataType = DbType.&lt;#=col.DbType.ToString()#&gt;, IsNullable = &lt;#=col.IsNullable.ToString().ToLower()#&gt;, AutoIncrement = &lt;#=col.AutoIncrement.ToString().ToLower()#&gt;, IsForeignKey = &lt;#=col.IsForeignKey.ToString().ToLower()#&gt;, MaxLength = &lt;#=col.MaxLength#&gt; }); </code></pre> <p>The problem is that once you cleaned up the column names, SubSonic tries the find the valid columns in your query by matching your SubSonic generated <strong>property names</strong> against the database's original <strong>column names</strong>.</p> <p>These changes will make sure that SubSonic be matching them against the cleaned <strong>property name</strong>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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