Note that there are some explanatory texts on larger screens.

plurals
  1. POSubSonic Dynamic Schema: SelectList
    primarykey
    data
    text
    <h2>Scenario</h2> <p>I am using SubSonic for my latest project. First things first; this project is constrained to using .net 3.0 and SubSonic has been GREAT. I love it.</p> <p>However, I'm having some trouble with customization. The customer has requested that we use two SQL Server 2005 databases, one of which will replicate the other, minus some columns.</p> <p>At first glance this seems like a no brainer. However, SubSonic grabs all the columns by default, causing SQLExceptions. I would like to <em>elegantly</em> limit the select list on a table by table basis.</p> <p>For instance, the following code will do the trick, but I would rather not need to do so every time I new up a query:</p> <pre><code>Query q = Post.Query().WHERE(Post.Columns.PageId, page_id); if(UsingReplicatedDB) q.SetSelectList(ReplicatedPostColumnList); return q.ExecuteReader(); </code></pre> <h2>The Question</h2> <p>The above method bloats my code and does not work for the builtin <code>FetchByX</code> methods generated by SubSonic. Is there a way to elegantly set the <strong>default</strong> SelectList on a table by table basis?</p> <h2>Notes</h2> <p>I have tried removing columns from the Schema at runtime in my partial classes, but columns looking like <code>ColNameColumn</code> look for specific indices in the <code>Columns</code> collection so my plan was foiled.</p> <h2>I know, I know</h2> <p>Please no "You are an idiot, why would you do this?" answers. I understand there are most likely better ways and this seems a bit hacky, but this is the point I'm at. I need a solution not badgering.</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. 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