tags:

views:

357

answers:

3

SubSonic is great and helps me code a lot faster, but now I've run into something that I think would help a ton of programmers.

I'm programming against a huge database, but only need about 6 or 7 tables out of the 50 or so tables. The exclude in the Settings.ttinclude requires me to enter the other tables not needed. I would love to have a IncludeTables string array that speeds up the entry of the tables that are required for the application.

Hopefully the team at the SubSonic project already have a patch/fix for this.

[Edited] I see that v2.2 has includeTableList and whole list of other configuration options. Where do I set these in v3.0.0.2???

+1  A: 

I'm no SubSonic expert but if you are using the ActiveRecord t4 templates, you can just edit the template itself.

Look in SQLServer.ttinclude:

const string TABLE_SQL=@"SELECT *
    FROM  INFORMATION_SCHEMA.TABLES";

Just add a WHERE clause to the above to include only the tables you want.

sestocker
This is a really simple and elegant solution.
James
+1  A: 

Sestocker - Thanks for that... I believe that would work, but I have the solution that I want:

In the Settings.ttinclude I have a IncludeTables variable below the ExcludeTables variable:

string[] ExcludeTables = new string[]{
....
};

string[] IncludeTables = new string[]{
....
};

Then I updated the ActiveRecord.tt and Context.tt, changing the code that checks the ExcludeTables:

if(!ExludeTables.Contains(tbl.Name))
....

to this

if(IncludeTables.Contains(tbl.Name))
....

so I made sure that any reference to the "!ExcludeTables" was changed to "IncludeTables".

It generated the classes I needed, but I have not tested it yet.

I'll see if I can work on the t4 templates a bit to have the code work with both Exclude and Include and see if I can post it online later today or tomorrow.

kntcnrg
Still working on the code unless someone else already made the changes that allows for a developer to use one set of templates and not two separate templates (one for ExcludeTables and another for IncludeTables).
kntcnrg
A: 

The goal of having T4 templates is so you can do for yourself - not ask us to fix it (not that we mind honestly - but it's easier for you). In this case most people have just a few tables they want to exclude.

That said, in the next rev I'll make the method more generic so you can change it as needed (rather than check an array - I should ask "ShouldGenerate()").

Rob Conery
Thanks Rob. I knew we could change the T4 templates as that's part of the whole concept of the ALT.NET community; I just don't have a lot of time and patience to sit at work and work on it. I really appreciate your time and your efforts to help out the development community with such an awesome tool.On behalf of the development community, thank you! ;)
kntcnrg