Question

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?

Was it helpful?

Solution

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;   
        }
    }

OTHER TIPS

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;
  }
}

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top