Reputation: 29365
I want to use PetaPoco on a table that has circa 600 tables, but I only want to map a handful of the tables.
Is there a way to explicitly state the tables I want mapping? The config in the t4 template (tables["tablename"].Ignore = true
) doesn't really scale to this approach?
Upvotes: 2
Views: 1398
Reputation: 454
I have done something similar
var tablesToLoad= new string[] {
"TableOne",
"TableTwo",
"ViewOne",
"Etc" };
var tables = LoadTables();
foreach(var t in tables)
{
if(!tablesToLoad.Contains(t.Name))
{
t.Ignore = true;
}
}
Upvotes: 2
Reputation: 2503
To avoid having a T4 template filled with ignore assignments, I made a new database user that only had access to the tables I needed.
Then I connected the T4 template with the database user and PetaPoco only saw the tables I needed.
Upvotes: 1
Reputation: 29365
I ended up doing it like this:
Tables tables = LoadTables();
foreach(Table t in tables)
{
if(!t.Name.Contains("all_user_group"))
{
t.Ignore = true;
}
}
Upvotes: 4