Scenario
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.
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.
At first glance this seems like a no brainer. However, SubSonic grabs all the columns by default, causing SQLExceptions. I would like to elegantly limit the select list on a table by table basis.
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:
Query q = Post.Query().WHERE(Post.Columns.PageId, page_id);
if(UsingReplicatedDB)
q.SetSelectList(ReplicatedPostColumnList);
return q.ExecuteReader();
The Question
The above method bloats my code and does not work for the builtin FetchByX
methods generated by SubSonic. Is there a way to elegantly set the default SelectList on a table by table basis?
Notes
I have tried removing columns from the Schema at runtime in my partial classes, but columns looking like ColNameColumn
look for specific indices in the Columns
collection so my plan was foiled.
I know, I know
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.